OpenSearch/docs/reference/search
uboness 7d6ad8d91c Added extended_bounds support for date_/histogram aggs
By default the date_/histogram returns all the buckets within the range of the data itself, that is, the documents with the smallest values (on which with histogram) will determine the min bucket (the bucket with the smallest key) and the documents with the highest values will determine the max bucket (the bucket with the highest key). Often, when when requesting empty buckets (min_doc_count : 0), this causes a confusion, specifically, when the data is also filtered.

To understand why, let's look at an example:

Lets say the you're filtering your request to get all docs from the last month, and in the date_histogram aggs you'd like to slice the data per day. You also specify min_doc_count:0 so that you'd still get empty buckets for those days to which no document belongs. By default, if the first document that fall in this last month also happen to fall on the first day of the **second week** of the month, the date_histogram will **not** return empty buckets for all those days prior to that second week. The reason for that is that by default the histogram aggregations only start building buckets when they encounter documents (hence, missing on all the days of the first week in our example).

With extended_bounds, you now can "force" the histogram aggregations to start building buckets on a specific min values and also keep on building buckets up to a max value (even if there are no documents anymore). Using extended_bounds only makes sense when min_doc_count is 0 (the empty buckets will never be returned if the min_doc_count is greater than 0).

Note that (as the name suggest) extended_bounds is **not** filtering buckets. Meaning, if the min bounds is higher than the values extracted from the documents, the documents will still dictate what the min bucket will be (and the same goes to the extended_bounds.max and the max bucket). For filtering buckets, one should nest the histogram agg under a range filter agg with the appropriate min/max.

Closes #5224
2014-03-20 14:48:27 +01:00
..
aggregations Added extended_bounds support for date_/histogram aggs 2014-03-20 14:48:27 +01:00
facets [Doc] doc updates for date histogram interval 2014-03-14 18:55:32 +01:00
request [DOCS] Reword clear-scroll sentence 2014-03-17 12:08:49 +01:00
suggesters ContextSuggester 2014-03-13 11:24:46 +01:00
aggregations.asciidoc [DOCS] Various aggregation doc fixes 2014-03-13 09:05:25 +01:00
count.asciidoc [DOCS] fixed count docs, it now requires a top-level query object, same as other apis 2014-02-13 13:36:20 +01:00
explain.asciidoc [DOCS] updated json responses after #4310 and #4480 2014-01-16 12:01:39 +01:00
facets.asciidoc Cleanup comments and class names s/ElasticSearch/Elasticsearch 2014-01-07 11:21:51 +01:00
more-like-this.asciidoc Migrated documentation into the main repo 2013-08-29 01:24:34 +02:00
multi-search.asciidoc [DOCS] Documented rest.action.multi.allow_explicit_index 2013-11-27 17:33:09 +01:00
percolate.asciidoc Introduced VersionType.FORCE & VersionType.EXTERNAL_GTE 2014-03-10 21:07:17 +01:00
request-body.asciidoc Add the ability to retrieve fields from field data 2014-01-21 09:13:32 -07:00
search.asciidoc [DOCS] Reorganised common API conventions 2013-10-13 16:46:56 +02:00
suggesters.asciidoc ContextSuggester 2014-03-13 11:24:46 +01:00
uri-request.asciidoc Cleanup comments and class names s/ElasticSearch/Elasticsearch 2014-01-07 11:21:51 +01:00
validate.asciidoc [DOCS] fixed count and validate query docs, they now require a top-level query object, same as other apis 2014-02-13 11:42:04 +01:00