[DOCS] Add usage tips to `top_hits` agg (#61215) (#61225)

This commit is contained in:
James Rodewig 2020-08-17 13:05:40 -04:00 committed by GitHub
parent e258c85b6a
commit 06d3159125
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -4,6 +4,10 @@
A `top_hits` metric aggregator keeps track of the most relevant document being aggregated. This aggregator is intended A `top_hits` metric aggregator keeps track of the most relevant document being aggregated. This aggregator is intended
to be used as a sub aggregator, so that the top matching documents can be aggregated per bucket. to be used as a sub aggregator, so that the top matching documents can be aggregated per bucket.
TIP: We do not recommend using `top_hits` as a top-level aggregation. If you
want to group search hits, use the <<collapse-search-results,`collapse`>>
parameter instead.
The `top_hits` aggregator can effectively be used to group result sets by certain fields via a bucket aggregator. The `top_hits` aggregator can effectively be used to group result sets by certain fields via a bucket aggregator.
One or more bucket aggregators determines by which properties a result set get sliced into. One or more bucket aggregators determines by which properties a result set get sliced into.
@ -30,6 +34,11 @@ The top_hits aggregation returns regular search hits, because of this many per h
IMPORTANT: If you *only* need `docvalue_fields`, `size`, and `sort` then IMPORTANT: If you *only* need `docvalue_fields`, `size`, and `sort` then
<<search-aggregations-metrics-top-metrics>> might be a more efficient choice than the Top Hits Aggregation. <<search-aggregations-metrics-top-metrics>> might be a more efficient choice than the Top Hits Aggregation.
`top_hits` does not support the <<rescore,`rescore`>> parameter. Query rescoring
applies only to search hits, not aggregation results. To change the scores used
by aggregations, use a <<query-dsl-function-score-query,`function_score`>> or
<<query-dsl-script-score-query,`script_score`>> query.
==== Example ==== Example
In the following example we group the sales by type and per type we show the last sale. In the following example we group the sales by type and per type we show the last sale.