Reputation: 462
I'm looking to use the Solr Suggester component for serving up search auto-complete suggestions.
I have created a field in my schema:
<fieldType name="text_autocomplete" class="solr.TextField">
<analyzer type="index">
<tokenizer class="solr.LowerCaseTokenizerFactory"/>
</analyzer>
</fieldType>
While my solrconfig.xml looks like:
<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">title_autocomplete</str>
<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.count">5</str>
<str name="spellcheck.collate">true</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
I am getting sensible results coming back, which is great. However, I would like to return the id field for the matching document rather than the field I am attempting to match against.
Upvotes: 1
Views: 1262
Reputation: 1420
The suggestion component is made to return you the most correlating words for a partial match to what you have typed in. Then if you need the documents that have a specific word from the list of suggestions, shoot another query to Solr (this time a different search handler) and get the doc ids back.
Upvotes: 1