[英]Elastic Search - Nested aggregation
I would like to form a nested aggregation type query in elastic search.我想在弹性搜索中形成一个嵌套的聚合类型查询。 Basically, the nested aggregation is at four levels.
基本上,嵌套聚合有四个级别。
groupId.keyword ---direction --billingCallType --durationCallAnswered groupId.keyword ---direction --billingCallType --durationCallAnswered
example:例子:
"aggregations": {
"avgCallDuration": {
"terms": {
"field": "groupId.keyword",
"size": 10000,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"show_term_doc_count_error": false,
"order": [
{
"_count": "desc"
},
{
"_key": "asc"
}
]
},
"aggregations": {
"call_direction": {
"terms" : {
"field": "direction"
},
"aggregations": {
"call_type" : {
"terms": {
"field": "billingCallType"
},
"aggregations": {
"avg_value": {
"terms": {
"field": "durationCallAnswered"
}
}
}
}
}
}
}
}
}
This is part of a query.这是查询的一部分。 While running this, I am getting the error as
运行此程序时,出现错误
"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 [direction] in order to load field data by uninverting the inverted index. Note that this can use significant memory." “type” :“illegal_argument_exception”, “reason” :“文本字段未针对需要每个文档字段数据的操作(如聚合和排序)进行优化,因此默认情况下禁用这些操作。请改用关键字字段。或者,设置fielddata=true on [direction] 以便通过反转倒排索引来加载字段数据。请注意,这可以使用重要的 memory。”
Can anyone throw light on this?任何人都可以对此有所了解吗?
As the error state, you are performing an aggregation on a text field, the field direction
.作为错误 state,您正在对文本字段(字段
direction
)执行聚合。
Aggregation are not supported by default on text field, as it is very expensive (cpu and memory wise).默认情况下,文本字段不支持聚合,因为它非常昂贵(cpu 和 memory 明智)。
They are 3 solutions to your issue,它们是您问题的 3 种解决方案,
fielddata: true
(flexible, but not optimised)fielddata: true
(灵活,但未优化)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.