索尔建议没有结果

时间:2016-05-04 14:55:47

标签: apache solr

我想将Solr建议器组件用于城市名称。我有以下设置:

schema.xml中

字段定义

<fieldType class="solr.TextField" name="textSuggest" positionIncrementGap="100">
  <analyzer>
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StandardFilterFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
</fieldType>

该字段我想在

上应用建议者
<field name="city" type="string"  indexed="true" stored="false"/>

复制字段

<copyField source="city" dest="citySuggest"/>

字段

<field name="citySuggest" type="textSuggest" stored="false" indexed="true" />

的solr-config.xml中

<requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy">
  <lst name="defaults">
    <str name="suggest">true</str>
    <str name="suggest.count">10</str>
    <str name="suggest.dictionary">mySuggester</str>
  </lst>
  <arr name="components">
    <str>suggest</str>
  </arr>
</requestHandler>



<searchComponent name="suggest" class="solr.SuggestComponent">
  <lst name="suggester">
    <str name="name">mySuggester</str>
    <str name="lookupImpl">FuzzyLookupFactory</str>      
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>    
    <str name="field">citySuggest</str>
    <str name="suggestAnalyzerFieldType">string</str>
  </lst>
</searchComponent>

然后我跑

http://localhost:8983/solr/company/suggest?suggest=true&suggest.dictionary=mySuggester&wt=json&suggest.q=Ath&suggest.build=true

构建建议组件

最后我跑

   http://localhost:8983/solr/company/suggest?suggest=true&suggest.dictionary=mySuggester&wt=json&suggest.q=Ath

但我得到一个空的结果集

{"responseHeader":{"status":0,"QTime":0},"suggest":{"mySuggester":{"Ath":{"numFound":0,"suggestions":[]}}}}

有没有明显的错误?有什么想法吗?

1 个答案:

答案 0 :(得分:4)

the以下:

  1. 在name =“citySuggest”的字段中设置属性stored =“true”。
  2. 然后重建建议者。