我的页面内容与&#34相同;财务费率为3.75%,市场....." 。现在,如果我输入搜索关键字为" 3.75%"然后结果应显示此页面,但它不起作用。它返回0结果但是当我输入" 3.75"它正常工作。作为搜索关键字。
public SearchResults<SearchHelper> GetSearchData(string searchtext)
{
using (searchContext)
{
//Fetch all items which contains search query
var query = searchContext.GetQueryable<SearchHelper>().OrderByDescending(i => i.BoostingValue).Where(i => (i.PageSearchContent.Contains(searchtext) ));
var result = query.GetResults();
return result;
}
}
任何人都可以帮助我如何允许使用特殊字符进行搜索?
由于
答案 0 :(得分:1)
您可以使用 WordDelimiterFilterFactory 过滤器将%转换为 DIGITAL 或 ALPHA
例如:
# A customized type mapping for WordDelimiterFilterFactory
# the allowable types are: LOWER, UPPER, ALPHA, DIGIT, ALPHANUM, SUBWORD_DELIM
#
# the default for any character without a mapping is always computed from
# Unicode character properties
# Map the $, %, '.', and ',' characters to DIGIT
# This might be useful for financial data.
% => DIGIT
( => ALPHA
) => ALPHA
. => DIGIT
使用示例
<filter class="solr.WordDelimiterFilterFactory" types="wdfftypes.txt" generateNumberParts="0" stemEnglishPossessive="0" splitOnCaseChange="1" preserveOriginal="1" catenateAll="1" catenateWords="1" catenateNumbers="1" generateWordParts="1" splitOnNumerics="1"/>
在solr / coreName / conf / wdfftypes.txt中创建一个名为“wdfftypes.txt”的新文件