SOLR 6.4.1的建议器(Suggester)是严格区分大小写的,如何使其不区分大小写?

4

我已经尝试了各种方法(毕竟它叫solr),让solr Suggest不区分大小写,但它仍然固执地区分大小写。

这会返回一个Mexican的建议:

http://localhost:8983/solr/mycollection/autocomplete?suggest.q=Mex

这个返回0个结果:

http://localhost:8983/solr/mycollection/autocomplete?suggest.q=mex

为了进一步诊断,我尝试了针对建议字段的小写/select搜索,成功返回包含“Mexican”的文档:

http://localhost:8983/solr/mycollection/select?q=suggestions:mex*

但是在使用Suggester时,使用小写字母并没有这样的好运。就好像我的<filter class="solr.LowerCaseFilterFactory"/>对Suggester没有影响一样。当然,在测试之前,我做了完整的配置上传、集合重新加载、数据重新索引和suggester重建。我正在运行云模式下的SOLR 6.4.1。有什么想法或者诊断提示吗? schema.xml
 <fieldType name="textSuggest" class="solr.TextField" positionIncrementGap="100">
      <analyzer>
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
 </fieldType>

<field name="recipe" type="text_general" indexed="true" stored="true" multiValued="false" />

<field name="suggestions" type="textSuggest" indexed="true" stored="true" multiValued="true" />

<copyField source="recipe" dest="suggestions"/>

solrconfig.xml

  <searchComponent class="solr.SuggestComponent" name="suggest">
    <lst name="suggester">
      <str name="name">foodsuggester</str>
      <str name="lookupImpl">WFSTLookupFactory</str>
      <str name="dictionaryImpl">DocumentDictionaryFactory</str>
      <str name="field">suggestions</str>
      <str name="buildOnStartup">false</str>
      <str name="buildOnCommit">false</str>
      <str name="storeDir">suggester_wfst_dir</str>
      <str name="suggestAnalyzerFieldType">textSuggest</str>
    </lst>
  </searchComponent>

  <requestHandler name="/autocomplete" class="solr.SearchHandler" startup="lazy">
      <lst name="defaults">
        <str name="suggest">true</str>
        <str name="suggest.dictionary">foodsuggester</str>
        <str name="suggest.count">10</str>
      </lst>
      <arr name="components">
        <str>suggest</str>
      </arr>
  </requestHandler>
2个回答

1
WFSTLookupFactory 显然不接受 suggestAnalyzerFieldType 参数,而且它会被忽略。您可以使用 AnalyzingLookupFactory,该工厂将根据 suggestAnalyzerFieldType 分析文本。因此,如果您只想分析建议器中的小写字母,则可以使用 suggestAnalzerFieldType 并通过 suggestAnalyzerFieldType 指示要使用 suggestText 字段类型进行分析。

1
似乎 WFSTLookupFactory 查询实现是区分大小写的。
如果没有特殊原因使用 WFSTLookupFactory,您可以使用 FuzzyLookupFactory
<str name="lookupImpl">FuzzyLookupFactory</str>

嘿,你说得对!FuzzyLookupFactory确实解决了问题!唯一的问题是,我不想要模糊的结果,我只需要大小写不敏感的精确建议。虽然如此,这是一个很大的进步,谢谢。 - Magnus
1
好的,模糊工厂返回仅精确不区分大小写匹配,通过添加 <str name="nonFuzzyPrefix">40</str> 来实现,这意味着前40个字符必须完全匹配(忽略大小写)。它完美地运作,并仍然允许更短的精确匹配,就像在我的情况下一样。 - Magnus

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接