Link Search Menu Expand Document

Options

  • size: how many terms to return

Cook

GET /_search
{
  "aggs": {
    "genres": {
      "terms": { "field": "genre" } 
    }
  }
}
{
  ...
  "aggregations": {
    "genres": {
      "doc_count_error_upper_bound": 0,   
      "sum_other_doc_count": 0,           
      "buckets": [                        
        {
          "key": "electronic",
          "doc_count": 6
        },
        {
          "key": "rock",
          "doc_count": 3
        },
        {
          "key": "jazz",
          "doc_count": 2
        }
      ]
    }
  }
}
  • sum_other_doc_count: when there are lots of unique terms, Elasticsearch only returns the top terms; this number is the sum of the document counts for all buckets that are not part of the response

Copyright © 2020 Thence LLC