Skip to content

Commit d5b03f6

Browse files
authored
[DOCS] Move search sort docs to separate page (elastic#60123)
Moves the search sort docs from the deprecated 'Request Body Search' page to a new subpage of 'Run a search'. No substantive changes were made to the content.
1 parent 003a68f commit d5b03f6

12 files changed

+39
-30
lines changed

docs/painless/painless-contexts.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ specialized code may define new ways to use a Painless script.
2323
| Reindex | <<painless-reindex-context, Painless Documentation>>
2424
| {ref}/docs-reindex.html[Elasticsearch Documentation]
2525
| Sort | <<painless-sort-context, Painless Documentation>>
26-
| {ref}/search-request-body.html#request-body-search-sort[Elasticsearch Documentation]
26+
| {ref}/sort-search-results.html[Elasticsearch Documentation]
2727
| Similarity | <<painless-similarity-context, Painless Documentation>>
2828
| {ref}/index-modules-similarity.html[Elasticsearch Documentation]
2929
| Weight | <<painless-weight-context, Painless Documentation>>

docs/painless/painless-contexts/painless-sort-context.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
=== Sort context
33

44
Use a Painless script to
5-
{ref}/search-request-body.html#request-body-search-sort[sort] the documents in a query.
5+
{ref}/sort-search-results.html[sort] the documents in a query.
66

77
*Variables*
88

docs/reference/aggregations/metrics/top-metrics-aggregation.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ faster.
4949
==== `sort`
5050

5151
The `sort` field in the metric request functions exactly the same as the `sort` field in the
52-
<<request-body-search-sort, search>> request except:
52+
<<sort-search-results, search>> request except:
5353
* It can't be used on <<binary,binary>>, <<flattened,flattened>>, <<ip,ip>>,
5454
<<keyword,keyword>>, or <<text,text>> fields.
5555
* It only supports a single sort value so which document wins ties is not specified.

docs/reference/aggregations/pipeline/bucket-sort-aggregation.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ is ascending.
3838
[options="header"]
3939
|===
4040
|Parameter Name |Description |Required |Default Value
41-
|`sort` |The list of fields to sort on. See <<request-body-search-sort,`sort`>> for more details. |Optional |
41+
|`sort` |The list of fields to sort on. See <<sort-search-results,`sort`>> for more details. |Optional |
4242
|`from` |Buckets in positions prior to the set value will be truncated. |Optional | `0`
4343
|`size` |The number of buckets to return. Defaults to all buckets of the parent aggregation. |Optional |
4444
|`gap_policy` |The policy to apply when gaps are found in the data (see <<gap-policy>> for more

docs/reference/query-dsl/has-child-query.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Add together the relevance scores of all matching child documents.
131131
[[has-child-query-performance]]
132132
===== Sorting
133133
You cannot sort the results of a `has_child` query using standard
134-
<<request-body-search-sort,sort options>>.
134+
<<sort-search-results,sort options>>.
135135

136136
If you need to sort returned documents by a field in their child documents, use
137137
a `function_score` query and sort by `_score`. For example, the following query

docs/reference/query-dsl/has-parent-query.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ You can use this parameter to query multiple indices that may not contain the
112112
[[has-parent-query-performance]]
113113
===== Sorting
114114
You cannot sort the results of a `has_parent` query using standard
115-
<<request-body-search-sort,sort options>>.
115+
<<sort-search-results,sort options>>.
116116

117117
If you need to sort returned documents by a field in their parent documents, use
118118
a `function_score` query and sort by `_score`. For example, the following query

docs/reference/redirects.asciidoc

+5-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ See <<request-body-search-search-type>>.
132132

133133
[role="exclude",id="search-request-sort"]
134134
=== Sort parameter for request body search API
135-
See <<request-body-search-sort>>.
135+
See <<sort-search-results>>.
136136

137137
[role="exclude",id="search-request-source-filtering"]
138138
=== Source filtering parameter for request body search API
@@ -946,4 +946,8 @@ See <<highlighting>>.
946946
[role="exclude",id="highlighter-internal-work"]
947947
==== How highlighters work internally
948948
See <<how-highlighters-work-internally>>.
949+
950+
[role="exclude",id="request-body-search-sort"]
951+
==== Sort
952+
See <<sort-search-results>>.
949953
////

docs/reference/scripting/fields.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ each of which is explained below.
3636
=== Accessing the score of a document within a script
3737

3838
Scripts used in the <<query-dsl-function-score-query,`function_score` query>>,
39-
in <<request-body-search-sort,script-based sorting>>, or in
39+
in <<sort-search-results,script-based sorting>>, or in
4040
<<search-aggregations,aggregations>> have access to the `_score` variable which
4141
represents the current relevance score of a document.
4242

docs/reference/search/request-body.asciidoc

+4-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ include::request/search-after.asciidoc[]
139139

140140
include::request/search-type.asciidoc[]
141141

142-
include::request/sort.asciidoc[]
142+
[[request-body-search-sort]]
143+
==== Sort
144+
145+
See <<sort-search-results>>.
143146

144147
include::request/source-filtering.asciidoc[]
145148

docs/reference/search/request/rescore.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Currently the rescore API has only one implementation: the query
1515
rescorer, which uses a query to tweak the scoring. In the future,
1616
alternative rescorers may be made available, for example, a pair-wise rescorer.
1717

18-
NOTE: An error will be thrown if an explicit <<request-body-search-sort,`sort`>>
18+
NOTE: An error will be thrown if an explicit <<sort-search-results,`sort`>>
1919
(other than `_score` in descending order) is provided with a `rescore` query.
2020

2121
NOTE: when exposing pagination to your users, you should not change

docs/reference/search/request/sort.asciidoc

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
[[request-body-search-sort]]
2-
==== Sort
1+
[[sort-search-results]]
2+
=== Sort search results
33

44
Allows you to add one or more sorts on specific fields. Each sort can be
55
reversed as well. The sort is defined on a per field level, with special
@@ -48,12 +48,12 @@ NOTE: `_doc` has no real use-case besides being the most efficient sort order.
4848
So if you don't care about the order in which documents are returned, then you
4949
should sort by `_doc`. This especially helps when <<request-body-search-scroll,scrolling>>.
5050

51-
===== Sort Values
51+
==== Sort Values
5252

5353
The sort values for each document returned are also returned as part of
5454
the response.
5555

56-
===== Sort Order
56+
==== Sort Order
5757

5858
The `order` option can have the following values:
5959

@@ -64,7 +64,7 @@ The `order` option can have the following values:
6464
The order defaults to `desc` when sorting on the `_score`, and defaults
6565
to `asc` when sorting on anything else.
6666

67-
===== Sort mode option
67+
==== Sort mode option
6868

6969
Elasticsearch supports sorting by array or multi-valued fields. The `mode` option
7070
controls what array value is picked for sorting the document it belongs
@@ -84,7 +84,7 @@ The default sort mode in the ascending sort order is `min` -- the lowest value
8484
is picked. The default sort mode in the descending order is `max` --
8585
the highest value is picked.
8686

87-
====== Sort mode example usage
87+
===== Sort mode example usage
8888

8989
In the example below the field price has multiple prices per document.
9090
In this case the result hits will be sorted by price ascending based on
@@ -109,7 +109,7 @@ POST /_search
109109
}
110110
--------------------------------------------------
111111

112-
===== Sorting numeric fields
112+
==== Sorting numeric fields
113113

114114
For numeric fields it is also possible to cast the values from one type
115115
to another using the `numeric_type` option.
@@ -227,7 +227,7 @@ To avoid overflow, the conversion to `date_nanos` cannot be applied on dates bef
227227
1970 and after 2262 as nanoseconds are represented as longs.
228228

229229
[[nested-sorting]]
230-
===== Sorting within nested objects.
230+
==== Sorting within nested objects.
231231

232232
Elasticsearch also supports sorting by
233233
fields that are inside one or more nested objects. The sorting by nested
@@ -253,7 +253,7 @@ field support has a `nested` sort option with the following properties:
253253
NOTE: Elasticsearch will throw an error if a nested field is defined in a sort without
254254
a `nested` context.
255255

256-
====== Nested sorting examples
256+
===== Nested sorting examples
257257

258258
In the below example `offer` is a field of type `nested`.
259259
The nested `path` needs to be specified; otherwise, Elasticsearch doesn't know on what nested level sort values need to be captured.
@@ -331,7 +331,7 @@ POST /_search
331331
Nested sorting is also supported when sorting by
332332
scripts and sorting by geo distance.
333333

334-
===== Missing Values
334+
==== Missing Values
335335

336336
The `missing` parameter specifies how docs which are missing
337337
the sort field should be treated: The `missing` value can be
@@ -357,7 +357,7 @@ GET /_search
357357
NOTE: If a nested inner object doesn't match with
358358
the `nested.filter` then a missing value is used.
359359

360-
===== Ignoring Unmapped Fields
360+
==== Ignoring Unmapped Fields
361361

362362
By default, the search request will fail if there is no mapping
363363
associated with a field. The `unmapped_type` option allows you to ignore
@@ -383,7 +383,7 @@ then Elasticsearch will handle it as if there was a mapping of type
383383
`long`, with all documents in this index having no value for this field.
384384

385385
[[geo-sorting]]
386-
===== Geo Distance Sorting
386+
==== Geo Distance Sorting
387387

388388
Allow to sort by `_geo_distance`. Here is an example, assuming `pin.location` is a field of type `geo_point`:
389389

@@ -438,7 +438,7 @@ have values for the field that is used for distance computation.
438438

439439
The following formats are supported in providing the coordinates:
440440

441-
====== Lat Lon as Properties
441+
===== Lat Lon as Properties
442442

443443
[source,console]
444444
--------------------------------------------------
@@ -462,7 +462,7 @@ GET /_search
462462
}
463463
--------------------------------------------------
464464

465-
====== Lat Lon as String
465+
===== Lat Lon as String
466466

467467
Format in `lat,lon`.
468468

@@ -485,7 +485,7 @@ GET /_search
485485
}
486486
--------------------------------------------------
487487

488-
====== Geohash
488+
===== Geohash
489489

490490
[source,console]
491491
--------------------------------------------------
@@ -506,7 +506,7 @@ GET /_search
506506
}
507507
--------------------------------------------------
508508

509-
====== Lat Lon as Array
509+
===== Lat Lon as Array
510510

511511
Format in `[lon, lat]`, note, the order of lon/lat here in order to
512512
conform with http://geojson.org/[GeoJSON].
@@ -531,7 +531,7 @@ GET /_search
531531
--------------------------------------------------
532532

533533

534-
===== Multiple reference points
534+
==== Multiple reference points
535535

536536
Multiple geo points can be passed as an array containing any `geo_point` format, for example
537537

@@ -560,7 +560,7 @@ The final distance for a document will then be `min`/`max`/`avg` (defined via `m
560560

561561

562562

563-
===== Script Based Sorting
563+
==== Script Based Sorting
564564

565565
Allow to sort based on custom scripts, here is an example:
566566

@@ -588,7 +588,7 @@ GET /_search
588588
--------------------------------------------------
589589

590590

591-
===== Track Scores
591+
==== Track Scores
592592

593593
When sorting on a field, scores are not computed. By setting
594594
`track_scores` to true, scores will still be computed and tracked.
@@ -609,7 +609,7 @@ GET /_search
609609
}
610610
--------------------------------------------------
611611

612-
===== Memory Considerations
612+
==== Memory Considerations
613613

614614
When sorting, the relevant sorted field values are loaded into memory.
615615
This means that per shard, there should be enough memory to contain

docs/reference/search/run-a-search.asciidoc

+2
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,5 @@ include::request/from-size.asciidoc[]
271271
include::search-fields.asciidoc[]
272272

273273
include::request/highlighting.asciidoc[]
274+
275+
include::request/sort.asciidoc[]

0 commit comments

Comments
 (0)