我正在使用 solr 中的过去搜索来制作自动建议功能。Synonyms.txt 包含常见拼写错误/拼写错误等的列表。它设置为在索引上运行并使用管理员中的分析工具我可以看到它工作正常 - 但它似乎不适用于实时数据。
Field type :
<field name="suggest_ngrams" type="text_ngram" indexed="true" stored="false" multiValued="true" />
Schema:
<fieldType name="text_ngram" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords_en.txt" enablePositionIncrement="true"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="false"/>
<filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="15" side="front"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords_en.txt" enablePositionIncrement="true"/>
</analyzer>
and an example of synonyms.txt
watch, watches, watche, watchs => watch
因此,在索引时,我希望“watche”被“watch”取代——情况似乎并非如此(即使分析工具说这就是它正在做的事情。
要清楚,如果我查询 solr (?q=watc) 短语“watche”出现在结果中
任何想法或见解都会受到赞赏,因为我认为一切都设置正确
谢谢