Varun Hegde
Varun Hegde

Reputation: 349

Returning an entire Document on Solr Suggestion

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>

Upvotes: 0

Views: 842

Answers (1)

YoungHobbit
YoungHobbit

Reputation: 13402

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.

Upvotes: 1

Related Questions