From 5d5859b85ff82d67c8195df35b9c1ccc90a80765 Mon Sep 17 00:00:00 2001 From: Clinton Gormley Date: Mon, 2 Mar 2015 10:54:52 +0100 Subject: [PATCH] Update search-type.asciidoc Changed search_type docs to reflect that the `(dfs_)query_and_fetch` modes are an internal optimization and should not be specified explicitly by the user. Relates to #9606 --- .../search/request/search-type.asciidoc | 57 ++++++++++--------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/docs/reference/search/request/search-type.asciidoc b/docs/reference/search/request/search-type.asciidoc index 7c4e74679c1df..73349d7889a2a 100644 --- a/docs/reference/search/request/search-type.asciidoc +++ b/docs/reference/search/request/search-type.asciidoc @@ -34,42 +34,25 @@ to execute on a *per search request* basis. The type can be configured by setting the *search_type* parameter in the query string. The types are: -[[query-and-fetch]] -==== Query And Fetch - -Parameter value: *query_and_fetch*. - -The most naive (and possibly fastest) implementation is to simply -execute the query on all relevant shards and return the results. Each -shard returns `size` results. Since each shard already returns `size` -hits, this type actually returns `size` times `number of shards` results -back to the caller. - [[query-then-fetch]] ==== Query Then Fetch Parameter value: *query_then_fetch*. -The query is executed against all shards, but only enough information is -returned (*not the document content*). The results are then sorted and -ranked, and based on it, *only the relevant shards* are asked for the -actual document content. The return number of hits is exactly as -specified in `size`, since they are the only ones that are fetched. This -is very handy when the index has a lot of shards (not replicas, shard id -groups). +The request is processed in two phases. In the first phase, the query +is forwarded to *all involved shards*. Each shard executes the search +and generates a sorted list of results, local to that shard. Each +shard returns *just enough information* to the coordinating node +to allow it merge and re-sort the shard level results into a globally +sorted set of results, of maximum length `size`. + +During the second phase, the coordinating node requests the document +content (and highlighted snippets, if any) from *only the relevant +shards*. NOTE: This is the default setting, if you do not specify a `search_type` in your request. -[[dfs-query-and-fetch]] -==== Dfs, Query And Fetch - -Parameter value: *dfs_query_and_fetch*. - -Same as "Query And Fetch", except for an initial scatter phase which -goes and computes the distributed term frequencies for more accurate -scoring. - [[dfs-query-then-fetch]] ==== Dfs, Query Then Fetch @@ -97,3 +80,23 @@ Parameter value: *scan*. The `scan` search type disables sorting in order to allow very efficient scrolling through large result sets. See <> for more. +[[query-and-fetch]] +==== Query And Fetch + +Parameter value: *query_and_fetch*. + +The `query_and_fetch` mode is an *internal* optimization which +is chosen automatically when a `query_then_fetch` request +targets a single shard only. Both phases of `query_then_fetch` +are executed in a single pass. This mode should not be +explicitly specified by the user. + +[[dfs-query-and-fetch]] +==== Dfs, Query And Fetch + +Parameter value: *dfs_query_and_fetch*. + +Same as `query_and_fetch`, except for an initial scatter phase which +goes and computes the distributed term frequencies for more accurate +scoring. This mode should not be explicitly specified by the user. +