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?