From 7a8f8608daecf02f1923545ec9e2beef49b12fbc Mon Sep 17 00:00:00 2001 From: James Rodewig <40268737+jrodewig@users.noreply.github.com> Date: Tue, 11 Aug 2020 10:28:07 -0400 Subject: [PATCH] [DOCS] Move post filter/rescore content to new page (#60903) (#60962) --- docs/reference/redirects.asciidoc | 12 ++++++++++- .../search/filter-search-results.asciidoc | 20 +++++++++++++++++++ docs/reference/search/request-body.asciidoc | 12 ++++++++--- .../search/request/post-filter.asciidoc | 13 ++++++------ .../reference/search/request/rescore.asciidoc | 17 ++++++++++------ .../search/search-your-data.asciidoc | 1 + 6 files changed, 59 insertions(+), 16 deletions(-) create mode 100644 docs/reference/search/filter-search-results.asciidoc diff --git a/docs/reference/redirects.asciidoc b/docs/reference/redirects.asciidoc index 806639590bb15..44ef7c6c142f3 100644 --- a/docs/reference/redirects.asciidoc +++ b/docs/reference/redirects.asciidoc @@ -91,7 +91,7 @@ See <>. [role="exclude",id="search-request-post-filter"] === Post filter parameter for request body search API -See <>. +See <>. [role="exclude",id="search-request-preference"] === Preference parameter for request body search API @@ -1022,6 +1022,16 @@ See <>. See <. +[role="exclude",id="request-body-search-post-filter"] +=== Post filter + +See <>. + +[role="exclude",id="request-body-search-rescore"] +=== Rescoring + +See <>. + [role="exclude",id="request-body-search-script-fields"] ==== Script fields diff --git a/docs/reference/search/filter-search-results.asciidoc b/docs/reference/search/filter-search-results.asciidoc new file mode 100644 index 0000000000000..d59c7a91973e2 --- /dev/null +++ b/docs/reference/search/filter-search-results.asciidoc @@ -0,0 +1,20 @@ +[[filter-search-results]] +== Filter search results + +You can use two methods to filter search results: + +* Use a boolean query with a `filter` clause. Search requests apply +<> to both search hits and +<>. + +* Use the search API's `post_filter` parameter. Search requests apply +<> only to search hits, not aggregations. You can use +a post filter to calculate aggregations based on a broader result set, and then +further narrow the results. ++ +You can also <> hits after the post filter to +improve relevance and reorder results. + +include::request/post-filter.asciidoc[] + +include::request/rescore.asciidoc[] diff --git a/docs/reference/search/request-body.asciidoc b/docs/reference/search/request-body.asciidoc index 36d9bcb609838..330036cbf7655 100644 --- a/docs/reference/search/request-body.asciidoc +++ b/docs/reference/search/request-body.asciidoc @@ -140,14 +140,20 @@ See <>. See <>. -include::request/post-filter.asciidoc[] +[[request-body-search-post-filter]] +==== Post filter + +See <>. include::request/preference.asciidoc[] -include::request/rescore.asciidoc[] +[[request-body-search-rescore]] +==== Rescoring + +See <>. [[request-body-search-script-fields]] -==== Script Fields +==== Script fields See <>. diff --git a/docs/reference/search/request/post-filter.asciidoc b/docs/reference/search/request/post-filter.asciidoc index 3e7c01e28a7e6..b4e75bbf45871 100644 --- a/docs/reference/search/request/post-filter.asciidoc +++ b/docs/reference/search/request/post-filter.asciidoc @@ -1,11 +1,12 @@ -[[request-body-search-post-filter]] -==== Post filter +[discrete] +[[post-filter]] +=== Post filter -The `post_filter` is applied to the search `hits` at the very end of a search -request, after aggregations have already been calculated. Its purpose is -best explained by example: +When you use the `post_filter` parameter to filter search results, the search +hits are filtered after the aggregations are calculated. A post filter has no +impact on the aggregation results. -Imagine that you are selling shirts that have the following properties: +For example, you are selling shirts that have the following properties: [source,console] -------------------------------------------------- diff --git a/docs/reference/search/request/rescore.asciidoc b/docs/reference/search/request/rescore.asciidoc index 6606553665e47..6f82416c17b09 100644 --- a/docs/reference/search/request/rescore.asciidoc +++ b/docs/reference/search/request/rescore.asciidoc @@ -1,10 +1,11 @@ -[[request-body-search-rescore]] -==== Rescoring +[discrete] +[[rescore]] +=== Rescore filtered search results Rescoring can help to improve precision by reordering just the top (eg 100 - 500) documents returned by the <> and -<> phases, using a +<> phases, using a secondary (usually more costly) algorithm, instead of applying the costly algorithm to all documents in the index. @@ -23,11 +24,13 @@ NOTE: when exposing pagination to your users, you should not change `from` values) since that can alter the top hits causing results to confusingly shift as the user steps through pages. -===== Query rescorer +[discrete] +[[query-rescorer]] +==== Query rescorer The query rescorer executes a second query only on the Top-K results returned by the <> and -<> phases. The +<> phases. The number of docs which will be examined on each shard can be controlled by the `window_size` parameter, which defaults to 10. @@ -82,7 +85,9 @@ for <> rescores. |`min` |Take the min of the original score and the rescore query score. |======================================================================= -===== Multiple Rescores +[discrete] +[[multiple-rescores]] +==== Multiple rescores It is also possible to execute multiple rescores in sequence: diff --git a/docs/reference/search/search-your-data.asciidoc b/docs/reference/search/search-your-data.asciidoc index 529d46fb4d2d8..19de6c9dcc9ff 100644 --- a/docs/reference/search/search-your-data.asciidoc +++ b/docs/reference/search/search-your-data.asciidoc @@ -229,6 +229,7 @@ GET /*/_search // TEST[setup:my_index] include::request/collapse.asciidoc[] +include::filter-search-results.asciidoc[] include::request/highlighting.asciidoc[] include::{es-repo-dir}/async-search.asciidoc[] include::{es-repo-dir}/search/near-real-time.asciidoc[]