-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Labels
Description
Elasticsearch 7.10.2 - 7.12.0
Plugins installed: []
JVM version (java -version): openjdk 11.0.10 2021-01-19
OS version Ubuntu 20.10
Description of the problem including expected versus actual behavior:
When using profile=true in REST requests, global sub aggregation results seem to be scoped by the query
Steps to reproduce:
PUT /test/_doc/1
{
"aField": "A"
}
PUT /test/_doc/2
{
"aField": "B"
}
PUT /test/_doc/3
{
"aField": "B"
}
POST /test/_search
{
"profile": "true",
"size":0,
"query": {
"term": {
"aField.keyword": {
"value": "B"
}
}
},
"aggs": {
"aGlobal": {
"global": {},
"aggs": {
"aTerm": {
"terms": {
"field": "aField.keyword",
"size": 10
}
}
}
}
}
}
It should return
(...)
"aggregations" : {
"aGlobal" : {
"doc_count" : 3,
"aTerm" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "B",
"doc_count" : 2
},
{
"key" : "A",
"doc_count" : 1
}
]
}
}
}
(...)
but instead we get (the only difference being "profile": "true" set in the request)
(...)
"aggregations" : {
"aGlobal" : {
"doc_count" : 2,
"aTerm" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "B",
"doc_count" : 2
}
]
}
}
},
(...)
Provide logs (if relevant):