This can be achieved using payloads in the suggester dictionary. The
suggester based on spellcheck component does not support payloads in
dictionary.
You can use the new suggester component (
https://issues.apache.org/jira/browse/SOLR-5378), which allows you to
highlight and return payloads.
The payload can only be one field from your search index (or you could also
use the file-based dictionaries).
Here is a solrconfig snippet that might be similar to what you want:

<searchComponent class="solr.SuggestComponent"
name="highlighting_suggester">
    <lst name="suggester">
      <str name="name">highlighting_suggester</str>
      <str
name="lookupImpl">org.apache.solr.spelling.suggest.fst.AnalyzingInfixLookupFactory</str>
<!-- suggester with highlighting support -->
      <str name="dictionaryImpl">DocumentDictionaryFactory</str> <!--
allows suggester to be built from the search index itself -->
      <str name="field">autocomplete</str> <!-- name of the field that the
suggestions will be based on -->
      <str name="weightField">relevance</str> <!-- (optional) weight used
for suggestions -->
      <str name="payloadField">group_info</str> <!-- payload field that
will be in the suggest results (this field can be something like
groupid:groupuser) -->
      <str name="suggestAnalyzerFieldType">text</str> <!-- field type
defined in schema that will be used to do index and query time processing
on the suggestions -->
      <!-- Suggester properties -->
      <!-- <str name="minPrefixChars">4</str>  -->
    </lst>
</searchComponent>

NOTE: currently the matched words are highlighted by  <b></b> tags

Hope that helps,
Areek

Reply via email to