gpt4 book ai didi

api - Elasticsearch 中的 mapper_parsing_exception(原因 : No type specified for field [X])

转载 作者:行者123 更新时间:2023-12-03 01:15:19 26 4
gpt4 key购买 nike

我想为文档中的字段提供显式映射,因此我为我的索引演示定义了一个映射,如下所示:

PUT /demo
{
"mappings": {
"properties": {
"X" : {
"X" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"Sub_X" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}


运行查询后,我收到以下错误:
{
"error" : {
"root_cause" : [
{
"type" : "mapper_parsing_exception",
"reason" : "No type specified for field [X]"
}
],
"type" : "mapper_parsing_exception",
"reason" : "Failed to parse mapping [_doc]: No type specified for field [X]",
"caused_by" : {
"type" : "mapper_parsing_exception",
"reason" : "No type specified for field [X]"
}
},
"status" : 400
}
json 文档中的字段 X 如下所示:
"X" : {
"X" : [
"a"
],
"Sub_X" : [
[
"b"
]
]
},
请帮我解决这个 Elasticsearch mapper_parse_exception 错误。

最佳答案

你所拥有的叫做nested data type
您有 X其中又包含 XSub_X .
映射:

{
"properties": {
"X": {
"type": "nested"
}
}
}

数据:
{
"X": {
"X": [
"a"
],
"Sub_X": [
[
"b"
]
]
}
}
查询:
{
"query": {
"nested": {
"path": "X",
"query": {
"bool": {
"must": [
{ "match": { "X.X": "a" }},
{ "match": { "X.Sub_X": "b" }}
]
}
}
}
}
}
它输出文档。

关于api - Elasticsearch 中的 mapper_parsing_exception(原因 : No type specified for field [X]),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62802268/

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