I am trying to implement auto-complete feature for search using Solr's suggester component. I want to give suggestions across multiple fields. I have 2 fields taxonomy
and tag
which I want to provide in suggestions. Eg if the search query is neck
then it should return:
necklace
neckalce sets
pearl necklace
diamond necklace
pearl necklace sets
diamond necklace sets
where necklace
is a taxonomy and pearl
and diamond
are tags.
Following is my schema.xml:
<field name="suggestion" type="text_auto" indexed="true" stored="false" multiValued="false" />
<copyField source="taxonomy_name" dest="suggestion"/>
<copyField source="tag" dest="suggestion">
<fieldType name="text_auto" class="solr.TextField">
<analyzer>
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
and my solrconfig.xml:
<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="field">suggestion</str> <!-- the indexed field to derive suggestions from -->
<float name="threshold">0.005</float>
<str name="buildOnCommit">true</str>
</lst>
</searchComponent>
<requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/suggest">
<lst name="defaults">
<str name="spellcheck">true</str>
<str name="spellcheck.dictionary">suggest</str>
<str name="spellcheck.onlyMorePopular">true</str>
<str name="spellcheck.count">5</str>
<str name="spellcheck.collate">true</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
But this returns:
necklace
necklace sets
How can I fix this. I also tried using :
<fieldType name="text_auto" class="solr.TextField">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
<filter class="solr.ShingleFilterFactory" maxShingleSize="2" outputUnigrams="false"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
</fieldType>
But this returns only necklace sets
.