Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solr Suggestion with multiple payloads

Tags:

solr

solrcloud

We are using Solr suggester feature for businessName lookup. As user enters the query, along with the matched names, we want solr to send other attributes from profile like id, address, city, state, country etc. fields.

I tried to configure multiple fields in solr suggester using payloadField tag but it is returning only the first field. I have tried putting them in comma separated fashion, but no luck. Here is the current config from solrconfig.xml file.

<searchComponent name="suggest" class="solr.SuggestComponent">
    <lst name="suggester">
        <str name="name">suggest</str>
        <str name="lookupImpl">AnalyzingLookupFactory</str>
        <str name="storeDir">suggester_fuzzy_dir</str>
        <str name="dictionaryImpl">DocumentDictionaryFactory</str>
        <str name="field">businessName</str>
        <str name="payloadField">profileId</str> 
        <str name="payloadField">email</str>
        <str name="payloadField">city</str>
        <str name="payloadField">state</str>
        <str name="payloadField">postalCode</str>
        <str name="payloadField">phoneNumber</str>
        <str name="weightField">businessName</str>
        <str name="suggestAnalyzerFieldType">text_general</str>
        <str name="buildOnStartup">true</str>
        <str name="buildOnCommit">true</str>
        <str name="preserveSep">false</str>
    </lst>
</searchComponent>

What configuration is required to send multiple payloads in result? Thanks.


Edit:
This is current output of the solr suggester.

    {
        "suggest": {
            "suggest": {
                "Rock": {
                    "numFound": 1,
                    "suggestions": [
                        {
                            "term": "Rockview Properties",
                            "weight": 0,
                            "payload": "123456789"
                        }
                    ]
                }
            }
        }
    }

My Expectation:
A way in which suggester payload contains more than one field. The payload field also contain the information that what data belongs to which field. I am not looking for copying all the data in a single field using copyField tag and then passing as payload approach.

like image 261
YoungHobbit Avatar asked Sep 07 '15 08:09

YoungHobbit


1 Answers

I have been doing online reading and search for the issue, sending multiple payload while returning solr suggester results. I found that, we can send only one field as payload from our index.

Reference: Link

Further suggestions are welcome.

like image 176
YoungHobbit Avatar answered Nov 05 '22 07:11

YoungHobbit