1

In solrconfig.xml,

Added a search component as below,

<searchComponent class="solr.SuggestComponent" name="suggest">
  <lst name="suggester">
    <str name="name">suggest</str>
    <str name="lookupImpl">FSTLookupFactory</str>
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>
    <str name="field">suggestions</str> //indexed field of type textspell
    <str name="weightField">price</str><!-- 
    <float name="threshold">0.005</float> -->
    <str name="buildOnCommit">true</str>
    <str name="suggestAnalyzerFieldType">string</str>
  </lst>
</searchComponent>

Then added a request handler to handle suggestions as below,

<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">suggest</str>
</lst>
<arr name="components">
    <str>suggest</str>
</arr></requestHandler>

In schema.xml added a field named suggestions as ,

<field  name="suggestions" type="textSpell" indexed="true" stored="false" multiValued="true" />

of field type textSpell defined as ,

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

After restarting and reindexing particular core named libshelf when I query,

http://localhost:8983/solr/libshelf/suggest?suggest=true&suggest.build=true&suggest.dictionary=suggest&wt=json&suggest.q=c

the result is,

{
"responseHeader": {
    "status": 0,
    "QTime": 32
},
"command": "build",
"suggest": {
    "suggest": {
        "c": {
            "numFound": 0,
            "suggestions": []
        }
    }
}}

More over the since the dicionaries for suggestions are based on indexed fields pagecontent and pagetitle, have created two copyfields to seed the suggesters as below,

<copyField source="pagecontent" dest="suggestions"/>
<copyField source="pagetitle" dest="suggestions"/>

How to resolve this issue?

Mysterion
  • 9,050
  • 3
  • 30
  • 52
BalaajiChander
  • 139
  • 3
  • 21
  • what kind of an issue? – Mysterion Feb 11 '15 at 13:30
  • No suggestions in response, But the pagecontent and pagetitle has almost 500+ text docs being indexed and stored in solr index... How to let solr look into the field indexes ( pagecontent and pagetitle ) , read and suggest ? Am I missing any configuration here ? – BalaajiChander Feb 11 '15 at 13:34
  • java.lang.IllegalArgumentException: len must be <= 32767; got 34826\ \ \ at org.apache.lucene.util.OfflineSorter$ByteSequencesWriter.write(OfflineSorter.java:479) – BalaajiChander Feb 11 '15 at 14:54
  • For solr5 and above , you can refer here: http://stackoverflow.com/questions/32862609/how-to-get-suggestions-in-solr-5-3-0 – Nikhil Sahu Oct 19 '15 at 13:06

0 Answers0