3. Tables & Charts

🏡 Home 👈 Prev 👉 Next
⚡  ElasticsearchBook.com is crafted by Jozef Sorocin and powered by:

From Docs through Counts to Aggregations

We typically write search queries with three goals in mind:
  1. retrieval of a (paginated) subset of documents
  1. getting the total count
  1. aggregating (grouping) based on a category — the usual suspect being e-shops facets
In this chapter we'll be specifically focusing on aggregations but before we do that, let's quickly talk about counting.

Approximate vs Exact Counts

Prior to v7.x, a _search request used to yield the exact total. From 7.0 onwards, you'll need to specify "track_total_hits": true in your _search payload. If this param is left out, ES will accurately count up only to 10,000 docs and then set the total.relation to gte. Stopping at 10K is a good trade-off to speed up searches.

Already purchased? Sign in here.