Solr建议器返回多次相同的结果,空权重

时间:2018-03-23 15:33:40

标签: solr search-suggestion

我对Solr的建议有以下问题:它返回的次数相同,并且所有权重都为零。我希望它只返回每个值一次,权重根据频率。

这是我的配置:

  <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>

当我打电话给例如建议?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":""}]

这可能吗?

谢谢!

1 个答案:

答案 0 :(得分:1)

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