Skip to content

terms aggs order messing up the results #70449

@shahzad31

Description

@shahzad31

Elasticsearch version:

SNAPSHOT-8.0.0 via Docker

Description of the problem including expected versus actual behavior:

If i specify order in the terms aggs, it returns less results.

With order specified

GET heartbeat-8*/_search
{
  "size": 0,
  "query": {
    "bool": {
      "filter": [
        {
          "terms": {
            "monitor.id": [
              "SimpleHTTP",
              "my-monitor-inline"
            ]
          }
        }
      ]
    }
  },
  "aggs": {
    "monitor": {
      "terms": {
        "field": "monitor.id",
        "size": 2,
        "order": {
          "_key": "asc"
        }
      }
    }
  }
}

Result will be

  "hits" : {
    "total" : {
      "value" : 10000,
      "relation" : "gte"
    },
    "max_score" : null,
    "hits" : [ ]
  },
  "aggregations" : {
    "monitor" : {
      "doc_count_error_upper_bound" : 0,
      "sum_other_doc_count" : 17102,
      "buckets" : [
        {
          "key" : "SimpleHTTP",
          "doc_count" : 132
        }
      ]
    }
  }

With no order specified query

  "aggs": {
    "monitor": {
      "terms": {
        "field": "monitor.id",
        "size": 2
      }
    }
  }

and result

"aggregations" : {
    "monitor" : {
      "doc_count_error_upper_bound" : 0,
      "sum_other_doc_count" : 0,
      "buckets" : [
        {
          "key" : "my-monitor-inline",
          "doc_count" : 17105
        },
        {
          "key" : "SimpleHTTP",
          "doc_count" : 135
        }
      ]
    }
  }

Data is standard heartbeat monitors data.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions