Executing a search with aggregations
Searching for results is obviously the main activity of a search engine; thus, aggregations are very important because they often help to augment the results.
Aggregations are executed along with the search by doing an analysis on the searched results.
Getting ready
You need a working ElasticSearch cluster and the packages used in the Creating a client recipe in this chapter.
The code of this recipe is in the chapter_11/aggregation.py
and chapter_11/aggregation_pyes.py
files, available in the code bundle of this book and on GitHub (https://github.com/aparo/elasticsearch-cookbook-second-edition).
How to do it...
In order to extend a query with aggregations, you need to define an aggregation section similar to what ...
Get ElasticSearch Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.