error in suggester component in solr

前端 未结 1 803
一个人的身影
一个人的身影 2021-01-07 08:49

I am working with solr auto complete functionality,I am using solr 4.50 to build my application, and I am following this link as a reference. My suggest component is somethi

相关标签:
1条回答
  • 2021-01-07 09:20

    I was able to get the autosuggest functionality working by using the Solr Term Component

    Add term components in your solrconfig.xml like this

    <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>
    

    define a field type for your autosuggest text in schema.xml

        <fieldType name="edgytext" class="solr.TextField" >  
          <analyzer>  
            <tokenizer class="solr.KeywordTokenizerFactory"/>  
            <filter class="solr.LowerCaseFilterFactory"/>  
          </analyzer>  
        </fieldType>
    

    add fields in schema.xml like this

       <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"/>
    

    Now the most important step... Remove all the folders from your index directory (can be found in solrconfig.xml ,.. look for <dataDir> tag)

    Restart the solr. and reindex your data. You will se new folders created in your index directory.

    You can check the auto suggest working by hitting the url -

    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(.*)
    
    0 讨论(0)
提交回复
热议问题