SOLR建议多场自动完成

时间:2011-10-10 12:17:01

标签: solr autosuggest

我为一个字段设置了自动完成的建议组件(它可以正常工作),但我需要多个字段吗?这可能吗?

我的solrconfig xml:

<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">name</str>
      <float name="threshold">0.005</float>
      <str name="buildOnCommit">true</str>
    </lst>
  </searchComponent>
  <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">10</str>
      <str name="spellcheck.collate">true</str>
    </lst>
    <arr name="components">
      <str>suggest</str>
    </arr>
  </requestHandler>

1 个答案:

答案 0 :(得分:9)

用户复制域将多个字段组合到单个字段中并在建议器中使用该字段 -

架构 -

<copyField source="name" dest="spell" />
<copyField source="other_name" dest="spell" />

建议者 -

<str name="field">spell</str>