【问题标题】:Removing unwanted items from solr autosuggester从 solr autosuggester 中删除不需要的项目
【发布时间】:2013-04-18 11:32:34
【问题描述】:

我正在尝试从大量已编入索引的段落中实现自动建议。但我想过滤掉自动建议中出现的某些不需要的词。例如,需要避免使用“and”、“how”、“when”等词。我该怎么办。

这是我在 solrconfig.xml 中为 autosuggest 所做的配置..

<requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/suggest">
    <lst name="defaults">
      <str name="spellcheck">true</str>
      <str name="spellcheck.dictionary">suggest</str>
      <str name="spellcheck.onlyMorePopular">true</str>
      <str name="spellcheck.count">5</str>
      <str name="spellcheck.collate">true</str>
    </lst>
    <arr name="components">
      <str>suggest</str>
    </arr>
  </requestHandler>


<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.tst.TSTLookup</str>

  <str name="field">keywords</str> 
  <float name="threshold">0.005</float>
  <str name="buildOnCommit">true</str>

</lst>

【问题讨论】:

    标签: solr lucene indexing lookup autosuggest


    【解决方案1】:

    我建议将StopFilterFactory 添加到schema.xml 文件中keywords 字段的支持fieldType 定义中。如果您在 keywords 字段中需要这些词(“and”、“how”、“when”)来满足其他搜索要求,我建议您在 schema.xml 中为建议者创建一个自定义字段,您可以使用copyField 指令来填充这个新字段。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-05
      • 1970-01-01
      • 2017-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多