0

i am trying to load the following data into an existing SOLR(6.6) core using the document upload section

   {
    "id": "1234",
    "nationality":"India",
    "phonenumber":"232323",
    "personname":"babu rao",
    "paid":"credi card",
    "status":"success",
    "access" :[
      {"port":"port1","gate":"Gate1"}
    ],
    "approved_by":[
      {"name":"appr1","date":"2006-11-30"},
      {"name":"appr2","date":"2006-11-30"}
    ]
  }

My Schema for this item is

 <field name="created_date" type="tdate" indexed="true" stored="true" />
 <field name="passType" type="string" indexed="true" stored="true" />
 <field name="duration" type="int" indexed="true" stored="true" />
 <field name="nationality" type="string" indexed="true" stored="true" />
 <field name="phonenumber" type="string" indexed="true" stored="true" />
 <field name="personname" type="string" indexed="true" stored="true" />
 <field name="paid" type="string" indexed="true" stored="true" />
 <field name="passamount" type="float" indexed="true" stored="true" />
 <field name="status" type="string" indexed="true" stored="true" />
 <field name="approved_by" type="string" indexed="true" stored="true" multiValued="true"/> 
 <field name="approved_by.name" type="string" indexed="true" stored="true" />
 <field name="approved_by.date" type="tdate" indexed="true" stored="true" />
 <field name="access" type="string" indexed="true" stored="true" multiValued="true"/> 
 <field name="access.port" type="string" indexed="true" stored="true" />
 <field name="access.gate" type="string" indexed="true" stored="true" />

I get the following error

Error parsing JSON field value. Unexpected OBJECT_START at [177], 
field=access

Request your help to resolve it.

1 Answer 1

1

_childDocuments_ key need to indicate the nested documents in JSON. I have updated the document now it will be Indexed.

{
    "id": "1234",
    "nationality":"India",
    "phonenumber":"232323",
    "personname":"babu rao",
    "paid":"credi card",
    "status":"success",
    "_childDocuments_" :[
      {"id":456,"port":"port1","gate":"Gate1"},
      {"id":786,"name":"appr1","date":"2006-11-30"},
      {"id":232,"name":"appr2","date":"2006-11-30"}
    ]
  }

Also You need to change the schema.xml.
[Schema.xml]

<field name="created_date" type="tdate" indexed="true" stored="true" />
 <field name="passType" type="string" indexed="true" stored="true" />
 <field name="duration" type="int" indexed="true" stored="true" />
 <field name="nationality" type="string" indexed="true" stored="true" />
 <field name="phonenumber" type="string" indexed="true" stored="true" />
 <field name="personname" type="string" indexed="true" stored="true" />
 <field name="paid" type="string" indexed="true" stored="true" />
 <field name="passamount" type="float" indexed="true" stored="true" />
 <field name="status" type="string" indexed="true" stored="true" />
 <field name="name" type="string" indexed="true" stored="true" />
 <field name="date" type="tdate" indexed="true" stored="true" />
 <field name="port" type="string" indexed="true" stored="true" />
 <field name="gate" type="string" indexed="true" stored="true" />

For More Information you can check this article by Yonik :- http://yonik.com/solr-nested-objects/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.