【发布时间】:2026-01-06 07:20:02
【问题描述】:
我正在使用 Solr v8.0.0,我尝试使用solr official documentation about Transforming JSON 中描述的方法在索引时拆分 json,但它没有按预期工作,最后我得到的是扁平 json .
这是我的做法:
首先我创建一个名为 C2 的单核
bin/solr create_core -c c2
然后,它的 solrconfig.xml 会自动创建并保留为默认值。
然后我尝试使用示例 URL 索引一些数据。唯一的区别是我在 URL 的末尾添加了一个 ?commit=true 以便我们可以看到发生了什么
curl 'http://localhost:8983/solr/c2/update/json/docs'\
'?commit=true'\
'?split=/'\
'&f=first:/first'\
'&f=last:/last'\
'&f=grade:/grade'\
'&f=subject:/exams/subject'\
'&f=test:/exams/test'\
'&f=marks:/exams/marks'\
-H 'Content-type:application/json' -d '
{
"first": "John",
"last": "Doe",
"grade": 8,
"exams": [
{
"subject": "Maths",
"test" : "term1",
"marks" : 90},
{
"subject": "Biology",
"test" : "term1",
"marks" : 86}
]
}'
但最后,我得到了这种索引,而不是示例中显示的索引:
我得到了什么:
{
{
"first":["John"],
"last":["Doe"],
"grade":[8],
"subject":["Maths",
"Biology"],
"test":["term1",
"term1"],
"marks":[90,
86],
"id":"284878be-1339-43b5-8a1e-adb7a4be95fb",
"_version_":1664059760532520960}]
}
我应该得到什么:
{
"first":"John",
"last":"Doe",
"marks":90,
"test":"term1",
"subject":"Maths",
"grade":8
}
{
"first":"John",
"last":"Doe",
"marks":86,
"test":"term1",
"subject":"Biology",
"grade":8
}
我的字段在正常索引中通常会变平,而 url 中没有 ?split=/ 命令。谁能帮我弄清楚为什么会发生这种行为?
谢谢。
【问题讨论】:
标签: json indexing solr split lucene