Uploading nested JSON objects to Solr

2019-08-25 05:58发布

I'm trying to send my inline JSON file to my Solr Database, but I'm having a problem with my nested objects.

I have two nested objects inside my _source object which are media_gallery and stock. Before my upload used to crash, but I managed to upload it after a few corrections, but my media_gallery and stock are added as separate objects therefore instead of having the original 1000 objects I get 3000 objects in my Solr DB after my upload.

I'm currently using this command to upload my JSON file:

curl 'http://192.168.99.100:8983/solr/gettingstarted/update/json/docs?split=/_source/media_gallery|/_source/stock&commit=true' \
     --data-binary @catalog.json \
     -H 'Content-type:application/json'

Basically I'm uploading the file catalog.json to http://192.168.99.100:8983/solr/gettingstarted.

My media_gallery and stock are both objects inside an object named _source and they're getting split as separate ones.

Could anyone help me with this? I need my media_gallery and stock objects to be uploaded as objects inside my source object one and not as a few separate ones.

Thank you.

Solution:

Basically there was no need for splitting the nested objects. Since i'm uploading everything as a single Solr document therefor i can use the the path "/".

curl 'http://192.168.99.100:8983/solr/gettingstarted/update/json/docs?split=&commit=true' --data-binary @catalog.json -H 'Content-type:application/json'

1条回答
Animai°情兽
2楼-- · 2019-08-25 06:58

You should change your split param (remove /_source/media_gallery & /_source/stock)

If the entire JSON makes a single Solr document, the path must be “/” Solr Guide: json mapping-parameters

查看更多
登录 后发表回答