【问题标题】:Change the solr suggest response based on a boost list of terms根据术语的提升列表更改 solr 建议响应
【发布时间】:2014-05-22 20:57:43
【问题描述】:

我需要在 solr 4.7.x 中根据每个术语的提升值自动建议响应,这种提升是针对文件中定义的某些术语集(企业可以管理此文件) .

我有一个设计来扩展现有的响应编写器或编写自定义插件,并且
例如:mydic.suggest 文件看起来像
老鹰 40.00 达到 20.00 托管 30.00l

当我开始打字时

-->查询1:“(http://example.com/solr/collection1/suggest?q=eag)”

原始 solr 响应将是(基于我的索引) 建议: {
渴望,
老鹰
}

因此建议响应应更改为
建议:{
老鹰,
急切
}

-->查询2:“(http://example.com/solr/collection1/suggest?q=ho)” 原始 Solr 响应将是(基于我的索引)

建议: { 假期,
冬青,
家,
故乡,
跳,
希望,
托管
}

因此建议响应应更改为 -- 观察“托管”一词出现

建议:{ 托管,
假期,
冬青,
家,
故乡,
跳,
希望
}

这可以通过自定义 solr 插件实现吗?

我的 Dic 建议处理程序看起来像 ::

<searchComponent class="solr.SpellCheckComponent" name="suggest">
    <lst name="spellchecker">
      <str name="name">suggest</str>
      <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
      <str name="lookupImpl">org.apache.solr.spelling.suggest.fst.WFSTLookupFactory</str>
      <!-- Alternatives to lookupImpl: 
           org.apache.solr.spelling.suggest.fst.FSTLookupFactory   [finite state automaton]
           org.apache.solr.spelling.suggest.fst.WFSTLookupFactory [weighted finite state automaton]
           org.apache.solr.spelling.suggest.jaspell.JaspellLookupFactory [default, jaspell-based]
           org.apache.solr.spelling.suggest.tst.TSTLookupFactory   [ternary trees]

      <str name="comparatorClass">freq</str>-->
      <str name="sourceLocation ">./../suggest/autoSuggestDic.txt</str>
      <str name="field">textSuggest</str>  <!-- the indexed field to derive suggestions from -->
      <str name="buildOnCommit">true</str>
      <bool name="exactMatchFirst">true</bool>
    </lst>
     <!-- specify a fieldtype using keywordtokenizer + lowercase + cleanup -->
    <str name="queryAnalyzerFieldType">text_general</str>
  </searchComponent>
  <requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/suggest">
    <lst name="defaults">
      <str name="name">suggest</str>
      <str name="spellcheck">true</str>
      <str name="spellcheck.dictionary">suggest</str>
      <str name="spellcheck.onlyMorePopular">false</str>
      <str name="spellcheck.count">15</str>   
      <str name="spellcheck.collate">true</str>
    </lst>
    <arr name="components">
      <str>suggest</str>
    </arr>
  </requestHandler>

【问题讨论】:

  • 是的,我已经使用我的 dic 为我的 suugest 处理程序进行了该设置 #simple auto-suggest phrase dictionary for testing # 注意这使用制表符作为分隔符!霍华德 100.0 命中 3.0 测试 3.0 鹰 5.0 船尾 5.0 显示 5.0 仅供参考,我建议的 dic 处理程序看起来像 - 请参阅我更新的问题,感谢 Srikanth 的建议。

标签: solr solrj autosuggest solr4 solrcloud


【解决方案1】:

我现在可以使用 solr 4.7 来支持字典和索引字典。

我的自定义建议处理程序构建 HighFrequencyDictionary(使用我的索引构建)实例和 FileDictionary(这是我提到的字典文件

./../autoSuggestDic.dic in solrConfig.xml) 实例

在 build(...) 方法中 和自定义 getSuggestions(SpellingOptions options){..} 方法使用这两个字典进行建议。

这类似于提升您的建议词作为搜索结果的提升。

【讨论】:

    猜你喜欢
    • 2012-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-11
    相关资源
    最近更新 更多