admin管理员组文章数量:1530279
es 聚合查询,根据tags字段进行聚合查询
GET /ecommerce/product/_search
{
"aggs":{
"group_by_tags" :{
"terms": {
"field": "tags"
}
}
}
}
发生异常
Text fields are not optimised for operations that require per-document field data like aggregations and sorting,
so these operations are disabled by default. Please use a keyword field instead.
Alternatively, set fielddata=true on [tags] in order to load field data by uninverting the inverted index.
Note that this can use significant memory.
完整错误信息:
{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [tags] in order to load field data by uninverting the inverted index. Note that this can use significant memory."
}
],
"type" : "search_phase_execution_exception",
"reason" : "all shards failed",
"phase" : "query",
"grouped" : true,
"failed_shards" : [
{
"shard" : 0,
"index" : "ecommerce",
"node" : "jxkP5bULTYaYdJ0k9GWdPw",
"reason" : {
"type" : "illegal_argument_exception",
"reason" : "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [tags] in order to load field data by uninverting the inverted index. Note that this can use significant memory."
}
}
],
"caused_by" : {
"type" : "illegal_argument_exception",
"reason" : "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [tags] in order to load field data by uninverting the inverted index. Note that this can use significant memory.",
"caused_by" : {
"type" : "illegal_argument_exception",
"reason" : "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [tags] in order to load field data by uninverting the inverted index. Note that this can use significant memory."
}
}
},
"status" : 400
}
解决办法: 更新索引mapping,将需要聚合的字段fielddata设置为true
#修改索引的mapping
PUT /ecommerce/_mapping
{
"properties" : {
"tags" : {
"type":"text",
"fielddata": true
}
}
}
版权声明:本文标题:Elasticsearch7.x聚合查询发生异常 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1725721866a1038473.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论