solr中的suggester组件中的错误

时间:2013-10-28 09:37:00

标签: solr autocomplete lucene

我正在使用solr auto complete功能,我正在使用solr 4.50构建我的应用程序,并且我正在关注this链接作为参考。我的建议组件是这样的

  <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="storeDir">suggest</str>
      <str name="field">autocomplete_text</str>
      <bool name="exactMatchFirst">true</bool>
      <float name="threshold">0.005</float>
      <str name="buildOnCommit">true</str>
      <str name="buildOnOptimize">true</str>
    </lst>
   <lst name="spellchecker">
      <str name="name">jarowinkler</str>  
      <str name="field">lowerfilt</str>  
      <str name="distanceMeasure">org.apache.lucene.search.spell.JaroWinklerDistance</str>  
      <str name="spellcheckIndexDir">spellchecker</str>  
   </lst>
     <str name="queryAnalyzerFieldType">edgytext</str>  
  </searchComponent>

但是,我收到以下错误

org.apache.solr.spelling.suggest.Suggester  – Loading stored lookup data failed
java.io.FileNotFoundException: /home/anurag/Downloads/solr-4.4.0/example/solr/collection1/data/suggest/tst.dat (No such file or directory)

它说有些文件丢失但是solr wiki suggester组件说它支持这些lookupImpls -

<str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookup</str>
      <!-- Alternatives to lookupImpl: 
           org.apache.solr.spelling.suggest.fst.FSTLookup   [finite state automaton]
           org.apache.solr.spelling.suggest.fst.WFSTLookupFactory [weighted finite state automaton]
           org.apache.solr.spelling.suggest.jaspell.JaspellLookup [default, jaspell-based]
           org.apache.solr.spelling.suggest.tst.TSTLookup   [ternary trees]
      -->

不知道我做错了什么.....任何帮助都会深深感激

1 个答案:

答案 0 :(得分:1)

我可以使用Solr Term Component

获取自动提示功能

在您的solrconfig.xml中添加术语组件

<searchComponent name="terms" class="solr.TermsComponent"/>
  <!-- A request handler for demonstrating the terms component -->
  <requestHandler name="/terms" class="solr.SearchHandler" startup="lazy">
     <lst name="defaults">
      <bool name="terms">true</bool>
      <bool name="distrib">false</bool>
    </lst>     
    <arr name="components">
      <str>terms</str>
    </arr>
  </requestHandler>

为schema.xml

中的autosuggest文本定义字段类型
    <fieldType name="edgytext" class="solr.TextField" >  
      <analyzer>  
        <tokenizer class="solr.KeywordTokenizerFactory"/>  
        <filter class="solr.LowerCaseFilterFactory"/>  
      </analyzer>  
    </fieldType>

像这样添加schema.xml中的字段

   <field name="name"  type="edgytext" indexed="true" stored="true" />  

   <field name="autocomplete_text" type="edgytext" indexed="true" stored="false"  multiValued="true" omitNorms="true" omitTermFreqAndPositions="false" />

   <copyField source="name" dest="autocomplete_text"/>

现在最重要的一步...从索引目录中删除所有文件夹 (可在solrconfig.xml中查找,..查找<dataDir>代码)

重新启动solr。并重新索引您的数据。您将在索引目录中创建新文件夹。

您可以通过点击网址检查自动建议工作 -

http://127.0.0.1:8983/solr/your_core/terms?terms.fl=autocomplete_text&omitHeader=true&terms.limit=20&terms.sort=index&terms.regex=(.*)your_query(.*)