0

我正在尝试使用 solr 的 terms 组件进行自动完成,但没有返回任何结果。

我的查询:

/solr/terms?&terms.fl=autocomplete_field&wt=json&omitHeader=true

我的架构:

<field name="autocomplete_field" type="text_tag" indexed="true" stored="true" required="false" multiValued="true" termVectors="true" />

<fieldType name="text_tag" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="solr.KeywordTokenizerFactory"/>
    <!-- in this example, we will only use synonyms at query time
    <filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
    -->
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.KeywordTokenizerFactory"/>
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
  </analyzer>
</fieldType>

我的结果:

{"terms":{"autocomplete_field":{}}}
4

1 回答 1

0

是否启用了术语组件。你能检查是否terms设置为true。

 <searchComponent name="termsComponent" class="solr.TermsComponent"/>

 <requestHandler name="/terms" class="solr.SearchHandler">
   <lst name="defaults">
     <bool name="terms">true</bool>
   </lst>
   <arr name="components">
     <str>termsComponent</str>
   </arr>
 </requestHandler>

您也可以terms=true作为请求参数传递并检查。

于 2013-01-31T04:34:47.703 回答