gpt4 book ai didi

elasticsearch - 在 Elasticsearch 中执行聚合查询时出错。 “illegal_argument_exception/默认情况下,在文本字段上禁用了字段数据

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

嗨,我正在执行对 Elasticsearch 实例的curl请求。但是我收到如下错误。

curl -X GET "localhost:57457/mep-reports*/_search?pretty&size=0" -H 'Content-Type: application/json' --data-binary @query.txt

Response.

{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "Fielddata is disabled on text fields by default. Set fielddata=true on [status] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
}
],
"type" : "search_phase_execution_exception",
"reason" : "all shards failed",
"phase" : "query",
"grouped" : true,
"failed_shards" : [
{
"shard" : 0,
"index" : "mep-reports",
"node" : "NJuAFq3YSni4TIK9PzgJxg",
"reason" : {
"type" : "illegal_argument_exception",
"reason" : "Fielddata is disabled on text fields by default. Set fielddata=true on [status] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
}
}
],
"caused_by" : {
"type" : "illegal_argument_exception",
"reason" : "Fielddata is disabled on text fields by default. Set fielddata=true on [status] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.",
"caused_by" : {
"type" : "illegal_argument_exception",
"reason" : "Fielddata is disabled on text fields by default. Set fielddata=true on [status] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
}
}
},
"status" : 400
}

不知道如何解决它。以下是我得到的映射定义
curl-XGET"localhost:57457/mep-reports*/_mapping/field/*?pretty"


{
"mep-reports":{
"mappings":{
"doc":{
"_index":{
"full_name":"_index",
"mapping":{

}
},
"status.keyword":{
"full_name":"status.keyword",
"mapping":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"inventory":{
"full_name":"inventory",
"mapping":{
"inventory":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
}
}
},
"flight_name.keyword":{
"full_name":"flight_name.keyword",
"mapping":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"nof_segments":{
"full_name":"nof_segments",
"mapping":{
"nof_segments":{
"type":"long"
}
}
},
"_all":{
"full_name":"_all",
"mapping":{

}
},
"_ignored":{
"full_name":"_ignored",
"mapping":{

}
},
"campaign_name":{
"full_name":"campaign_name",
"mapping":{
"campaign_name":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
}
}
},
"_parent":{
"full_name":"_parent",
"mapping":{

}
},
"flight_id.keyword":{
"full_name":"flight_id.keyword",
"mapping":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"flight_name":{
"full_name":"flight_name",
"mapping":{
"flight_name":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
}
}
},
"@version":{
"full_name":"@version",
"mapping":{
"@version":{
"type":"long"
}
}
},
"_version":{
"full_name":"_version",
"mapping":{

}
},
"campaign_id":{
"full_name":"campaign_id",
"mapping":{
"campaign_id":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
}
}
},
"_routing":{
"full_name":"_routing",
"mapping":{

}
},
"_type":{
"full_name":"_type",
"mapping":{

}
},
"msg_text":{
"full_name":"msg_text",
"mapping":{
"msg_text":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
}
}
},
"delivery_ts":{
"full_name":"delivery_ts",
"mapping":{
"delivery_ts":{
"type":"long"
}
}
},
"sender.keyword":{
"full_name":"sender.keyword",
"mapping":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"submission_ts":{
"full_name":"submission_ts",
"mapping":{
"submission_ts":{
"type":"long"
}
}
},
"flight_id":{
"full_name":"flight_id",
"mapping":{
"flight_id":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
}
}
},
"_seq_no":{
"full_name":"_seq_no",
"mapping":{

}
},
"@timestamp":{
"full_name":"@timestamp",
"mapping":{
"@timestamp":{
"type":"date"
}
}
},
"account_id":{
"full_name":"account_id",
"mapping":{
"account_id":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
}
}
},
"_field_names":{
"full_name":"_field_names",
"mapping":{

}
},
"sender":{
"full_name":"sender",
"mapping":{
"sender":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
}
}
},
"recipient":{
"full_name":"recipient",
"mapping":{
"recipient":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
}
}
},
"account_id.keyword":{
"full_name":"account_id.keyword",
"mapping":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"_source":{
"full_name":"_source",
"mapping":{

}
},
"_id":{
"full_name":"_id",
"mapping":{

}
},
"campaign_name.keyword":{
"full_name":"campaign_name.keyword",
"mapping":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"_uid":{
"full_name":"_uid",
"mapping":{

}
},
"recipient.keyword":{
"full_name":"recipient.keyword",
"mapping":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"inventory.keyword":{
"full_name":"inventory.keyword",
"mapping":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"msg_text.keyword":{
"full_name":"msg_text.keyword",
"mapping":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"status":{
"full_name":"status",
"mapping":{
"status":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
}
}
},
"campaign_id.keyword":{
"full_name":"campaign_id.keyword",
"mapping":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
}
}
}
}
}

非常感谢您的帮助。

最佳答案

根据该错误,您似乎正在尝试对text字段(即status)执行汇总。

请注意,您无法在aggregation字段上执行text,并且为此,您需要具有fielddata:true
但是,不建议这样做,因为它会消耗大量的堆空间,这是您在错误中看到的。

您共享的映射具有status字段的以下详细信息。

{
"status":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
}
}

我看到 statusstatus.keyword中有一个同级字段。

只需更改您的 query.txt中具有的查询,以在聚合查询中使用 status.keyword而不是 status,它就可以解决此问题。

同样,如果您看到更多类似的错误,则可能也希望在其他字段上也进行类似的更改。请注意,您需要在 aggregation查询中执行此更改。

让我知道这是否有帮助!

关于elasticsearch - 在 Elasticsearch 中执行聚合查询时出错。 “illegal_argument_exception/默认情况下,在文本字段上禁用了字段数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60707430/

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