October 2019
Beginner
186 pages
5h 39m
English
Leveraging patterns into queries optimizes the indexed data. For example, if all documents have a size field and most queries have range aggregations on a list of ranges, then the process can be performed faster by pre-indexing the ranges into the index with term aggregations:
PUT index/_doc/1{ "designation": "Sports shoes", "size": 8}
After indexing the documents, we can search them using the following query:
GET index/_search{ "aggs": { "size_ranges": { "range": { "field": "size", "ranges": [ { "to": 6 }, { "from": 6, "to": 12 }, { "from": 12 } ] } } }}
Using a keyword, the document can be furnished with size_range at index time:
PUT index{ "mappings": { "properties": { "size_range": { "type": "keyword" } } }}
The following ...
Read now
Unlock full access