Sunday, April 1, 2018

FW: Indexing multi level Nested JSON using curl

-----Original Message-----
From: Zheng Lin Edwin Yeo [mailto:edwinyeozl@gmail.com]
Sent: 30 March 2018 05:16
To: solr-user@lucene.apache.org
Subject: Re: Indexing multi level Nested JSON using curl

Hi,

Do anyone knows if we can make any change to the the split=/|/orgs in the
curl URL command to achieve the indexing of the multi-level Nested JSON?

Regards,
Edwin

On 26 March 2018 at 17:30, Zheng Lin Edwin Yeo <edwinyeozl@gmail.com> wrote:

> Hi,
>
> I'm trying to index the following JSON with 2 child level using the
> following curl command using cygwin:
>
> curl 'http://localhost:8983/solr/collection1/update/json/docs?spl
> it=/|/orgs'
> -H 'Content-type:application/json' -d '
> {
> "id":"1",
> "name_s": "JoeSmith",
> "phone_s": 876876687,
> "orgs": [
> {
> "name1_s" : "Microsoft",
> "city_s" : "Seattle",
> "zip_s" : 98052,
> "orgs":[{"name2_ss":"alan","phone2_ss":"123"},{"name2_ss":"
> edwin","phone2_ss":"456"}]
> },
> {
> "name1_s" : "Apple",
> "city_s" : "Cupertino",
> "zip_s" : 95014,
> "orgs":[{"name2_ss":"alan","phone2_ss":"123"},{"name2_ss":"
> edwin","phone2_ss":"456"}]
> }
> ]
> }'
>
> However, after indexing, this is what is shown in Solr. The 2nd child
> have been place together under the 1st child as a multi-valued field,
> which is wrong. If I have set the field for the 2nd child to be
> non-multi-valued field, it will have error saying "multiple values
> encountered for non multiValued field orgs2.name2_s:".
>
> {
> "responseHeader":{
> "zkConnected":true,
> "status":0,
> "QTime":41,
> "params":{
> "q":"phone_s:876876687",
> "fl":"*,[child parentFilter=phone_s:876876687]",
> "sort":"id asc"}},
> "response":{"numFound":1,"start":0,"docs":[
> {
> "id":"1",
> "name_s":"JoeSmith",
> "phone_s":"876876687",
> "language_s":"en",
> "_version_":1595632041779527680,
> "_childDocuments_":[
> {
> "name1_s":"Microsoft",
> "city_s":"Seattle",
> "zip_s":"98052",
> "orgs.name2_ss":["alan",
> "edwin"],
> "orgs.phone2_ss":["123",
> "456"],
> "_version_":1595632041779527680},
> {
> "name1_s":"Apple",
> "city_s":"Cupertino",
> "zip_s":"95014",
> "orgs.name2_ss":["alan",
> "edwin"],
> "orgs.phone2_ss":["123",
> "456"],
> "_version_":1595632041779527680}]}]
> }}
>
>
> How can we structure the curl command so it will be able to accept
> child of child relationship? We should not be doing any pre-processing
> to the JSON to achieve that.
>
> I'm using Solr 7.2.1.
>
> Regards,
> Edwin
>
>

No comments:

Post a Comment