OpenSearch/docs/reference/search
Mayya Sharipova 7cf170830c
Optimize sort on numeric long and date fields. (#49732)
This rewrites long sort as a `DistanceFeatureQuery`, which can
efficiently skip non-competitive blocks and segments of documents.
Depending on the dataset, the speedups can be 2 - 10 times.

The optimization can be disabled with setting the system property
`es.search.rewrite_sort` to `false`.

Optimization is skipped when an index has 50% or more data with
the same value.

Optimization is done through:
1. Rewriting sort as `DistanceFeatureQuery` which can
efficiently skip non-competitive blocks and segments of documents.

2. Sorting segments according to the primary numeric sort field(#44021)
This allows to skip non-competitive segments.

3. Using collector manager.
When we optimize sort, we sort segments by their min/max value.
As a collector expects to have segments in order,
we can not use a single collector for sorted segments.
We use collectorManager, where for every segment a dedicated collector
will be created.

4. Using Lucene's shared TopFieldCollector manager
This collector manager is able to exchange minimum competitive
score between collectors, which allows us to efficiently skip
the whole segments that don't contain competitive scores.

5. When index is force merged to a single segment, #48533 interleaving
old and new segments allows for this optimization as well,
as blocks with non-competitive docs can be skipped.

Backport for #48804


Co-authored-by: Jim Ferenczi <jim.ferenczi@elastic.co>
2019-11-29 15:37:40 -05:00
..
request [DOCS] Fix typo in search type docs (#48868) 2019-11-11 09:38:48 -05:00
suggesters [Docs] Fix typo in suggesters search API doc (#48477) 2019-10-29 09:58:05 +01:00
count.asciidoc [Docs] Fix _count HTTP method (#48979) 2019-11-12 15:45:26 +01:00
explain.asciidoc [DOCS] Reformats explain API (#46857) 2019-09-20 11:00:33 +02:00
field-caps.asciidoc [DOCS] Reformats Field capabilities API (#46866) 2019-09-20 11:28:19 +02:00
multi-search.asciidoc [DOCS] Change // CONSOLE comments to [source,console] (#46440) (#46494) 2019-09-09 12:35:50 -04:00
profile.asciidoc Optimize sort on numeric long and date fields. (#49732) 2019-11-29 15:37:40 -05:00
rank-eval.asciidoc Remove Ranking Evaluation API experimental status (#48603) 2019-10-29 20:57:39 +01:00
request-body.asciidoc Fix tag in the search request timeout option docs (#47776) 2019-10-10 10:35:44 +02:00
search-shards.asciidoc [DOCS] Change // CONSOLE comments to [source,console] (#46440) (#46494) 2019-09-09 12:35:50 -04:00
search-template.asciidoc [DOCS] Correct callouts in search template docs (#47655) 2019-10-07 09:25:32 -04:00
search.asciidoc [DOCS] Document `script_score` float precision limit (#49402) 2019-11-21 08:54:49 -05:00
suggesters.asciidoc [DOCS] Reformat suggesters page. (#47010) 2019-09-25 14:42:16 +02:00
uri-request.asciidoc [DOCS] [5 of 5] Change // TESTRESPONSE comments to [source,console-results] (#46449) (#46459) 2019-09-06 16:09:09 -04:00
validate.asciidoc [DOCS] Reformats validate API (#46389) 2019-09-18 14:31:17 +02:00