我一直在尝试为我的JSON架构定义正确的映射。但在尝试了所有可能的变量类型和其他属性后,我无法上传我的JSON。
在我的JSON中,我有一个密钥“P”,它本质上是嵌套的和复杂的。此元素存在于不同的兄弟级对象中,并展示文本,数组,嵌套,对象。
在我尝试加载JSON时创建架构后,它失败并出现以下错误
.filters-nav
.btn-group.m-r-15
button.btn.btn-inverse.dropdown-toggle.waves-effect.waves-light.btn-custom(type='button', data-toggle='dropdown', aria-expanded='false')
span.btn-label
i.fa.fa-filter
| Add filters
span.caret
ul.dropdown-menu.filters-dropdown(role='menu')
li
a(href='#', data-filter='table_1_filter_0') Instrument ID
li
a(href='#', data-filter='table_1_filter_1') Instrument Code
我不知道该怎么做 - 如果这个问题没有得到解决,我可能不得不切换到其他一些文本搜索数据库。请帮我理解哪里出错了。
我的映射JSON:
$ curl -XPnST 'http://localhost:9200/ridev2/1' -d @v22.jso
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Can't merge a non object mapping [EXPLA.SIDEHED.P] with an object mapping [EXPLA.SIDEHED.P]"}],"type":"illegal_argument_exception","reason":"Can't merge a non object mapping [EXPLA.SIDEHED.P] with an object mapping [EXPLA.SIDEHED.P]"},"status":400}
上传的真正JSON:
curl -XDELETE 'localhost:9200/ridev2?pretty'
curl -H 'Content-Type: application/json' -XPUT http://localhost:9200/ridev2 -d '{
"mappings": {
"title21": {
"properties": {
"CFRDOC": {
"properties": {
"AMDDATE": {
"type": "text"
},
"FMTR": {
"properties": {
"EXPLA": {
"properties": {
"PRTPAGE": {
"type": "object",
"properties": {
"_P": {
"type": "text"
}
}
},
"SIDEHED": {
"type": "object",
"properties": {
"HD": {
"type": "object"
},
"P": {
"type": "object",
"properties": {
"_": {
"type": "text"
},
"E": {
"type": "object",
"properties": {
"_": {
"type": "text"
},
"T": {
"type": "text"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
答案 0 :(得分:0)
我发现了json doc的两个问题。
1)映射对象的路径错误。如果要强制执行映射,则必须遵循相同的json路径来获取数据。
这应该是
{
"CFRDOC": {
"FMTR": {
"EXPLA": {
"SIDEHED": [
....
....
]
}
}
}
}
而不是
{
"EXPLA": {
"SIDEHED": [
........
]
}
}
2)在SIDEHEAD
内,nested_object P
被定义为映射中的对象,并且您提供了一个文本值,这会引发无效的映射解析。
这应该是
{
"HD": {
"_": "HOW TO USE THE CODE OF FEDERAL REGULATIONS",
"SOURCE": "HED"
},
"P": {
"_": [
"The Code of Federal Regulations is...atest version of any given rule.",
"To det..ent of any given rule."
]
}
}
而不是
{
"HD": {
"_": "HOW TO USE THE CODE OF FEDERAL REGULATIONS",
"SOURCE": "HED"
},
"P": [
"The Code of Federal Regulations is...atest version of any given rule.",
"To det..ent of any given rule."
]
}
根据您的映射确保您的json doc有效