Solr suggester returns 多次相同的结果,权重为空

Solr suggester returns many times the same results, with empty weights

我对 Solr 的建议程序有以下问题:它 returning 多次相同的值,并且所有权重都为零。我希望它 return 每个值只有一次,权重根据频率而定。

这是我的配置:

  <searchComponent name="suggest" class="solr.SuggestComponent">
    <lst name="suggester">
      <str name="name">infixSuggester</str>
      <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
      <str name="indexPath">infix_suggestions</str>
      <str name="dictionaryImpl">DocumentDictionaryFactory</str>
      <str name="field">title_suggest</str>
      <str name="suggestAnalyzerFieldType">phrase_suggest</str>
      <str name="buildOnStartup">true</str>
      <str name="buildOnCommit">true</str>
    </lst>
  </searchComponent>

  <requestHandler name="/suggest" class="solr.SearchHandler">
    <lst name="defaults">
      <str name="suggest.dictionary">infixSuggester</str>
      <str name="suggest.onlyMorePopular">true</str>
      <str name="suggest">true</str>
      <str name="suggest.count">500</str>
      <str name="suggest.collate">true</str>
    </lst>
    <arr name="components">
      <str>suggest</str>
    </arr>
  </requestHandler>

例如,当我调用 suggest?q=test 时,我得到类似这样的信息:

"suggestions":[{
    "term":"This is a test suggestion",
    "weight":0,
    "payload":""},
  {
    "term":"This is a test suggestion",
    "weight":0,
    "payload":""},
  {
    "term":"Another test example",
    "weight":0,
    "payload":""}]

所以我必须在我的客户端中进行处理以仅获得最受欢迎的完成。我希望有更接近于:

"suggestions":[{
    "term":"This is a test suggestion",
    "weight":2,
    "payload":""},
  {
    "term":"Another test example",
    "weight":1,
    "payload":""}]

这可能吗?

谢谢!

您可以使用 BlendedInfixLookupFactory 建议器,它是 AnalyzingInfixLookupFactory 的高级版本,为您提供其他功能并删除重复项。 . 双赢!