1

I setup suggester query in solr. I have the following setting,

Solar config

  <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">productSuggest</str>
      <str name="suggestAnalyzerFieldType">string</str>
    </lst>
  </searchComponent>

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

Schema file

  <field name="SpecMaterial" type="string" uninvertible="true" default="SpecMaterial" indexed="true" stored="true"/>

  <copyField source="SpecMaterial" dest="productSuggest" maxChars="30000"/>
  <field name="productSuggest" type="textSuggest" default="productSuggest" stored="true" indexed="true"/>

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

I run using this below url

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

But the suggester return 0 result like,

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

If any mistake are there in code? And why we can use copyfeild in suggester?

  • Did you build the suggester values with `suggest.build=true` in a request first? – MatsLindh Apr 17 '19 at 10:08
  • yes. I did using this URL –  Apr 17 '19 at 10:14
  • ```http://localhost:8983/solr/reliance_products/suggest?suggest.build=true``` –  Apr 17 '19 at 10:14
  • The output is ***{ "responseHeader":{ "status":0, "QTime":42}, "command":"build"}*** –  Apr 17 '19 at 10:14
  • Did you add any documents to your index, and what are their contents? (please add relevant information to the question instead of as single comments for each item) – MatsLindh Apr 17 '19 at 10:34
  • No. I didn't add documents to my code. –  Apr 17 '19 at 10:38
  • So if there are no documents in your index, what should the suggester return? The suggester is built from the documents in your index to return values that are relevant to the documents inside it - i.e. to suggest possible valid values from those that are present in the index. – MatsLindh Apr 17 '19 at 10:46
  • I have a doubt how to add document in index page? If any procedure are there? –  Apr 17 '19 at 10:50
  • You can add documents for testing through the "Documents" page in the admin interface. Usually you'll send these from your application to be stored in Solr for searching. – MatsLindh Apr 17 '19 at 11:25

0 Answers0