我试图允许在Solr中搜索部分字符串,因此,如果有人搜索"ppopota",他们将获得与搜索"hippopotamus"相同的结果.我上下阅读了文档,觉得自己已经用尽了所有的选择.到目前为止,我有以下内容:
I am trying to allow searches on partial strings in Solr so if someone searched for "ppopota" they'd get the same result as if they searched for "hippopotamus." I read the documentation up and down and feel like I have exhausted my options. So far I have the following:
定义新的字段类型:
<fieldtype name="testedgengrams" class="solr.TextField"> <analyzer> <tokenizer class="solr.LowerCaseTokenizerFactory"/> <filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="15" side="front"/> </analyzer> </fieldtype>定义"testedgengrams"类型的字段:
Defining a field of type "testedgengrams":
<field name="text_ngrams" type="testedgengrams" indexed="true" stored="false"/>将text_ngrams的内容复制到文本中
Copying contents of text_ngrams into text:
<copyField source="text_ngrams" dest="text"/>A,那是行不通的.我想念什么?
Alas, that doesn't work. What am I missing?
推荐答案您正在使用 EdgeNGramFilterFactory 会生成令牌"hi","hip","hipp"等,因此不会与"ppopota"匹配.请改用NGramFilterFactory.
You're using EdgeNGramFilterFactory which generates tokens 'hi', 'hip', 'hipp', etc, so it won't match 'ppopota'. Use NGramFilterFactory instead.
更多推荐
Solr部分和完整字符串匹配
发布评论