Aggs don't return all records

Hi , I've a problem with aggregations , the query we've in production in some scenarios don't return all counts.

query = {size: 0, :query=>{:filtered=>{:filter=>{:bool=>{:must=>[{:term=>{:account_id=>1}}, {:term=>{:user_id=>1}}], :must_not=>{:term=>{:state=>"deleted"}}}}}}, :aggs=>{"label_names"=>{:terms=>{:field=>"label_ids"}}}}

it return records but none all of them, I've reindexed the records but the results are innacurate, we are using only one node and ES version 2.3.3

any hints ?

Hi Miguel,

In terms aggregation elasticsearch returns by default the top 10 results. You can provide the size parameter to change it:

GET/_search
{
  "size": 0, 
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "account_id": {
              "value": "1"
            }
          }
        },
        {
          "term": {
            "user_id": {
              "value": "1"
            }
          }
        }
      ],
      "must_not": [
        {
          "term": {
            "state": {
              "value": "deleted"
            }
          }
        }
      ]
    }
  },
  "aggs": {
    "label_names": {
      "terms": {
        "field": "label_ids.keyword",
        "size": 15
      }
    }
  }
}

Please be aware that aggregations results can be approximated.

Hope it helps,
LG

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.