How to retrieve json in original nested form in apache solr?

折月煮酒 提交于 2019-12-25 08:04:03

问题


I am using apache solr for text search. I have nested document structure. This is one.json file :

{
"id": "1",
"info": {
       "first_name": "John",
       "last_name": "Doe",
       "gender": "male"
        }
}

I created a solr core and posted one.json in it.Solr indexed and flattened the above document's nested structure , I guess for better indexing in following form:

{
    "id":["1"],
    "info.first_name":["John"],
    "info.last_name":["Doe"],
    "info.gender":["male"]
}

Now, when I make the search query,the result is in flattened form.

For my requirement, I want the response json in original nested form.

How can this be achieved in Solr ? Is there some tool that I can use with Solr to get the original nested json while making search?

Addition:

I am using solr 6.3.0. When I added the json file to the core, solr automatically indexed the json file. A managed-schema.xml was generated by solr.

Here is a portion of managed-schema.xml where fields are defined:

<field name="_root_" type="string" docValues="false" indexed="true" stored="false"/>
  <field name="_text_" type="text_general" multiValued="true" indexed="true" stored="false"/>
  <field name="_version_" type="long" indexed="false" stored="false"/>
  <field name="id" type="string" multiValued="false" indexed="true" required="true" stored="true"/>
  <field name="info.first_name" type="strings"/>
  <field name="info.gender" type="strings"/>
  <field name="info.last_name" type="strings"/>

回答1:


This may be possible with srcField parameter as described in the Reference Guide section on processing custom JSON. Notice the limitation that your nested document will be indexed as a single document.

The techproduct example has the srcField configured, if you want to test it with a shipped schema.



来源:https://stackoverflow.com/questions/41566634/how-to-retrieve-json-in-original-nested-form-in-apache-solr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!