How do I parse nested JSON object?

What are the ways to Index nested json objects in solr?

  • I have a json object like this, {  "id" : "123",  "name" : "aaa",  "loc" : {    "city" : "xyz",    "state" : "abc"  },  }  In solr i added a field like, <field name="loc" type="string" indexed="true" stored="true" multiValued="true"/> Then i tried adding the json doc to solr But i couldn't see the 'loc' object being indexed in solr. Am i doing wrong? Do i need to add anything in schema.xml Can someone help me out of this pls?

  • Answer:

    I think multi-valued fields would be most appropriate for representing a list kind of structure. You can try to flatten the "loc" array and make separate fields like loc_city, loc_state etc. If the "city, state" fields are not fixed, you can probably mark them as dynamic fields.

Piyush Goel at Quora Visit the source

Was this solution helpful to you?

Other answers

Look at "Transforming and Indexing JSON" section in the SOLR programming guide. SOLR allows you to flatten and then make them searchable.... SOLR 5 and others have even better features in this area..

Sarnath Kannan

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.