I am trying to make a typehead autocomplete with SOLR using the suggester.
The search will be done for users and group names which aggregate users. The search will be done on usernames , bio , web page and other stuff. What I want to achieve is sort of "facebook" or "twitter" alike search. For this I need to enrich the result from SOLR with additional data (user type, url of the profile, his avatar url etc.).
The user and group would have the ID field in SOLR which would correspond to the ID in the DB to get these information. I am stuck on how to do that.
Currently I have the suggester working but it only returns the suggesting value, when I try to return some other attribute from the document it doesn't work.
Here is the part of the solrconfig:
<searchComponent class="solr.SpellCheckComponent" name="suggest">
<!-- configure the spellchecker used
for autocomplete (dictionary) -->
<lst name="spellchecker">
<str name="name">suggester_dictionary</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
<str name="lookupImpl">org.apache.solr.spelling.suggest.fst.FSTLookupFactory</str>
<!-- The indexed field to derive suggestions from -->
<str name="field">autocomplete</str>
<!-- buildOnCommit must be set to true because
suggester keeps data in memory -->
<str name="buildOnCommit">true</str>
</lst>
</searchComponent>
<requestHandler class="solr.SearchHandler" name="/suggest">
<lst name="defaults">
<!-- by default use the suggester_dictionary -->
<str name="spellcheck.dictionary">suggester_dictionary</str>
<str name="spellcheck.count">5</str>
<str name="spellcheck.onlyMorePopular">false</str>
</lst>
<lst name="invariants">
<!-- always run the Suggester for queries to this handler -->
<str name="spellcheck">true</str>
<!-- collate not needed, query if tokenized as keyword, we need only suggestions for that term -->
<str name="spellcheck.collate">false</str>
</lst>
<!-- this handler uses only the needed component :
suggest defined above -->
<arr name="components">
<str>suggest</str>
<str>highlight</str>
</arr>
</requestHandler>
and scheme:
<field name="groupid" type="int" indexed="true" stored="true"
required="true" multiValued="false"/>
<field name="groupusername" type="text_general" indexed="true"
stored="true" multiValued="true"/>
<field name="groupname" type="text_general" indexed="true"
stored="true" multiValued="false"/>
<field name="grouporuser" type="boolean" indexed="true"
stored="true" multiValued="false"/>
<field name="autocomplete" type="text_autocomplete"/>
<copyField source="groupusername" dest="autocomplete"/>
<copyField source="groupname" dest="autocomplete"/>
The query: http://gruppu.com:8983/solr/suggest?q=:&spellcheck.q=jo&spellcheck=true&hl=on&hl.fl=groupid
The respond:
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">0</int>
</lst>
<lst name="spellcheck">
<lst name="suggestions">
<lst name="jo">
<int name="numFound">2</int>
<int name="startOffset">0</int>
<int name="endOffset">2</int>
<arr name="suggestion">
<str>jorge</str>
<str>jorgen</str>
</arr>
</lst>
</lst>
</lst>
</response>
I would like to have the groupid and grouporuser fields returned ... No luck so far.