将嵌套的JSON对象上传到Solr [英] Uploading nested JSON objects to Solr
问题描述
我正在尝试将内联JSON文件发送到我的Solr数据库,但是我的嵌套对象有问题.
I'm trying to send my inline JSON file to my Solr Database, but I'm having a problem with my nested objects.
我的_source
对象中有两个嵌套对象,分别是media_gallery
和stock
.在我的上传崩溃之前,但经过几次更正后我设法上传了它,但是我的media_gallery
和stock
被添加为单独的对象,因此在原来的1000个对象之后,我在Solr DB中得到了3000个对象,而不是原来的对象.上载.
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.
我当前正在使用此命令上传我的JSON文件:
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'
基本上,我正在将文件catalog.json
上传到http://192.168.99.100:8983/solr/gettingstarted
.
Basically I'm uploading the file catalog.json
to http://192.168.99.100:8983/solr/gettingstarted
.
我的media_gallery
和stock
都是名为_source
的对象内的对象,它们将被拆分为单独的对象.
My media_gallery
and stock
are both objects inside an object named _source
and they're getting split as separate ones.
有人可以帮我吗?我需要将media_gallery
和stock
对象作为对象上传到源对象中,而不是作为几个单独的对象上传.
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.
谢谢.
解决方案:
基本上不需要拆分嵌套对象.由于我将所有内容作为单个Solr文档上载,因此我可以使用路径"/"
.
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'
推荐答案
您应更改拆分参数(删除/_ source/media_gallery 和/_ source/stock )
You should change your split param (remove /_source/media_gallery & /_source/stock)
如果整个JSON构成一个单个Solr文档,则路径必须为 "/" Solr指南:json映射-参数
If the entire JSON makes a single Solr document, the path must be "/" Solr Guide: json mapping-parameters
这篇关于将嵌套的JSON对象上传到Solr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!