0

Implemented a basic Solr Suggestion.I am able to get the suggested terms. But is there a way to return entire SOLR Document based on the suggestion?

Here is the searchComponent and requestHandler in solr_config.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.TSTLookupFactory</str>
 <str name="field">complete_search</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">10</str>
        <str name="spellcheck.collate">true</str>
    </lst>
    <arr name="components">
        <str>suggest</str>
    </arr>
</requestHandler>

The field and fieldType defintion in schema.xml are as follows.

 <field name="complete_search" type="text_auto" indexed="true"  stored="true" multiValued="true"/>

  <fieldType class="solr.TextField" name="text_auto">
   <analyzer>
    <tokenizer class="solr.KeywordTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
   </analyzer>
</fieldType>

The result I am getting is as follows:

<arr name="suggestion">
<str>global academy for learning</str>
<str>global art</str>
<str>global institute of fine arts</str>
<str>global kids</str>
<str>global music academy</str>
<str>global residential school</str>
<str>globetrippers</str>
<str>globetrotters</str>
<str>glorious kids</str>
<str>glow tennis academy</str>
</arr>

My query for is this http://localhost:8983/solr/core_name/suggest?q=glo

So is there a way to get output in the form of a SOLR Document as in

<doc>
    <str name="id">35716</str>
    <str name="PID">35716</str>
    <str name="service_name">Cherubs Montessori</str>
    <arr name="complete_search">
      <str>Cherubs Montessori</str>
      <str>Arts and Crafts</str>
      <str>No 173, 9th Main Road, 7th Sector, HSR Layout</str>
      <str>Bangalore</str>
      <str>HSR Layout</str>
    </arr>
    <str name="permalink">http://zp.local/extracurricular-activities/cherubs-montessori-at-hsr-layout-in-bangalore</str>
    <arr name="categories">
      <str>Arts and Crafts</str>
    </arr>
    <float name="average_ratings">0.0</float>
    <str name="lat_lng">12.9102859,77.6450215</str>
    <str name="listing_thumbnail">/uploads/2015/09/Cherubs-Montessori-300x122.jpg</str>
    <float name="maximum_age">14.0</float>
    <float name="minimum_age">5.0</float>
    <str name="address">No 173, 9th Main Road, 7th Sector, HSR Layout</str>
    <str name="city">Bangalore</str>
    <str name="locality">HSR Layout</str>
    <long name="_version_">1514279153996660736</long></doc>
  <doc>
Varun Hegde
  • 349
  • 2
  • 12

1 Answers1

1

It is not possible at the moment. You can send only one field in the payload attribute along with your suggestions. You can find more information here.

Community
  • 1
  • 1
YoungHobbit
  • 13,254
  • 9
  • 50
  • 73
  • 1
    Thanks for the link.So if i want to use an autosuggest with other payloads is it advisable to use a **N-Gram Tokenizer** or a **Edge N-Gram Tokenizer** tokenizer with the /select requestHandler?But that would significantly increase the size of my index right? – Varun Hegde Oct 07 '15 at 01:22
  • @Varun Yes, You are right. My knowledge is also that much. I am also looking for a solution for the same problem. – YoungHobbit Oct 07 '15 at 01:46
  • So, is there a way of providing the output of the suggestHandler as an input to the standardRequestHandler? – Varun Hegde Oct 07 '15 at 07:18
  • @Varun I am not aware of such thing. My guess is, it might not be possible, because the format of output and input has be compatible. – YoungHobbit Oct 07 '15 at 07:21