gpt4 book ai didi

java - Apache Solr 无法存储嵌套 JSON 数据

转载 作者:行者123 更新时间:2023-12-02 12:39:59 25 4
gpt4 key购买 nike

我正在尝试使用文档上传部分将以下数据加载到现有的 SOLR(6.6) 核心

   {
"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"}
]
}

我对此项目的架构是

 <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" />

我收到以下错误

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

请求您帮助解决该问题。

最佳答案

_childDocuments_ 键需要指示 JSON 中的嵌套文档。我已经更新了文档,现在它将被索引。

{
"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"}
]
}

您还需要更改 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" />

有关更多信息,您可以查看 Yonik 的这篇文章:- http://yonik.com/solr-nested-objects/

关于java - Apache Solr 无法存储嵌套 JSON 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44984779/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com