OpenSearch/docs/en/rest-api
Zachary Tong 9cc33f4e29 [Rollup] Select best jobs then execute msearch-per-job (elastic/x-pack-elasticsearch#4152)
If there are multiple jobs that are all the "best" (e.g. share the
best interval) we have no way of knowing which is actually the best.
Unfortunately, we cannot just filter for all the jobs in a single
search because their doc_counts can potentially overlap.

To solve this, we execute an msearch-per-job so that the results
stay isolated.  When rewriting the response, we iteratively
unroll and reduce the independent msearch responses into a single
"working tree".  This allows us to intervene if there are
overlapping buckets and manually choose a doc_count.

Job selection is found by recursively descending through the aggregation
tree and independently pruning the list of valid job caps in each branch.
When a leaf node is reached in the branch, the remaining jobs are
sorted by "best'ness" (see comparator in RollupJobIdentifierUtils for the
implementation) and added to a global set of "best jobs". Once
all branches have been evaluated, the final set is returned to the
calling code.

Job "best'ness" is, briefly, the job(s) that have
 - The largest compatible date interval
 - Fewer and larger interval histograms
 - Fewer terms groups

Note: the final set of "best" jobs is not guaranteed to be minimal,
there may be redundant effort due to independent branches choosing
jobs that are subsets of other branches.

Related changes:
- We have to include the job's ID in the rollup doc's
hash, so that different jobs don't overwrite the same summary
document.
- Now that we iteratively reduce the agg tree, the agg framework
injects empty buckets while we're working.  In most cases this
is harmless, but for `avg` aggs the empty bucket is a SumAgg while
any unrolled versions are converted into AvgAggs... causing a cast
exception.  To get around this, avg's are renamed to
`{source_name}.value` to prevent a conflict
- The job filtering has been pushed up into a query filter, since it
applies to the entire msearch rather than just individual agg components
- We no longer add a filter agg clause about the date_histo's interval, because 
that is handled by the job validation and pruning.

Original commit: elastic/x-pack-elasticsearch@995be2a039
2018-03-27 10:33:59 -07:00
..
graph [DOCS] Fixed cross-doc link to Graph Troubleshooting. 2017-06-28 13:01:35 -07:00
license Add api to start basic license (elastic/x-pack-elasticsearch#4083) 2018-03-12 14:39:58 -06:00
migration [DOCS] Added licensing APIs (elastic/x-pack-elasticsearch#4026) 2018-03-06 09:47:04 -08:00
ml [ML][DOCS] Remove empty rules from docs 2018-03-23 12:31:36 +00:00
rollup [Rollup] Select best jobs then execute msearch-per-job (elastic/x-pack-elasticsearch#4152) 2018-03-27 10:33:59 -07:00
security [DOCS] Role Mapping API improvements (elastic/x-pack-elasticsearch#3951) 2018-02-16 09:29:19 -08:00
watcher Watcher: Never return credentials after watch creation... (elastic/x-pack-elasticsearch#3581) 2018-02-20 10:09:27 +01:00
defs.asciidoc [DOCS] Added ML add and delete calendar event APIs (elastic/x-pack-elasticsearch#3394) 2018-01-24 08:14:23 -08:00
index.asciidoc [DOCS] Added licensing APIs (elastic/x-pack-elasticsearch#4026) 2018-03-06 09:47:04 -08:00
info.asciidoc Rollups for Elasticsearch (elastic/x-pack-elasticsearch#4002) 2018-02-23 17:10:37 -05:00
licensing.asciidoc Add api to start basic license (elastic/x-pack-elasticsearch#4083) 2018-03-12 14:39:58 -06:00
migration.asciidoc add Migration Deprecation Info API Documentation (elastic/x-pack-elasticsearch#2064) 2017-07-21 16:20:13 -07:00
ml-api.asciidoc [DOCS] Added ML add and delete calendar event APIs (elastic/x-pack-elasticsearch#3394) 2018-01-24 08:14:23 -08:00
rollup-api.asciidoc Rollups for Elasticsearch (elastic/x-pack-elasticsearch#4002) 2018-02-23 17:10:37 -05:00
security.asciidoc [DOCS] Added SSL certificates API (elastic/x-pack-elasticsearch#3136) 2018-01-17 08:14:02 -08:00
watcher.asciidoc Docs: Fixing failing docs build by removing leftover marker 2017-08-01 17:53:10 +02:00