Skip to content

Commit d08e502

Browse files
authored
Merge branch 'main' into cache-metrics-online-prewarming-type
2 parents 063e73f + 58a2939 commit d08e502

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

docs/reference/elasticsearch/rest-apis/sort-search-results.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,27 @@ GET /my-index-000001/_search
3636
{
3737
"sort" : [
3838
{ "post_date" : {"order" : "asc", "format": "strict_date_optional_time_nanos"}},
39-
"user",
4039
{ "name" : "desc" },
4140
{ "age" : "desc" },
41+
"user",
4242
"_score"
4343
],
4444
"query" : {
4545
"term" : { "user" : "kimchy" }
4646
}
4747
}
4848
```
49+
Order matters when defining multiple sort fields, because {{es}} attempts to sort on the first field in the array. Each subsequent field in the array is only used if the previous fields result in a tie. If documents have identical values across all specified sort fields, {{es}} uses the document ID as the final tie-breaker.
50+
51+
Here's how the example query attempts to sort results:
52+
53+
- First by `post_date`
54+
- If `post_date` values are identical, sorts by `name`
55+
- If both `post_date` and `name` are identical, sorts by `age`
56+
- If the first three fields are identical, sorts by `user`
57+
- If all previous fields are identical, sorts by `_score`
58+
59+
By default, Elasticsearch sorts `numeric` fields in descending order and `string` fields in ascending order unless you explicitly specify otherwise. All three formats shown in the example above are valid. Some make the sort order explicit, while others rely on Elasticsearch’s default behavior.
4960

5061
::::{note}
5162
`_doc` has no real use-case besides being the most efficient sort order. So if you don’t care about the order in which documents are returned, then you should sort by `_doc`. This especially helps when [scrolling](/reference/elasticsearch/rest-apis/paginate-search-results.md#scroll-search-results).

muted-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,9 @@ tests:
417417
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
418418
method: test {p0=transform/transforms_start_stop/Test start/stop/start continuous transform}
419419
issue: https://github.com/elastic/elasticsearch/issues/126755
420+
- class: org.elasticsearch.xpack.esql.qa.mixed.MixedClusterEsqlSpecIT
421+
method: test {keep.StatsBySubFieldSortedByKey SYNC}
422+
issue: https://github.com/elastic/elasticsearch/issues/126765
420423

421424
# Examples:
422425
#

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/180_match_operator.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ setup:
125125

126126
- match: { status: 400 }
127127
- match: { error.type: verification_exception }
128-
- match: { error.reason: "Found 1 problem\nline 1:19: Unknown column [something]" }
128+
- match: { error.reason: "/Unknown.column.\\[something\\]/" }
129129

130130
---
131131
"match on eval column":
@@ -139,7 +139,7 @@ setup:
139139

140140
- match: { status: 400 }
141141
- match: { error.type: verification_exception }
142-
- match: { error.reason: "Found 1 problem\nline 1:60: [:] operator cannot operate on [upper_content], which is not a field from an index mapping" }
142+
- match: { error.reason: "/operator.cannot.operate.on.\\[upper_content\\],.which.is.not.a.field.from.an.index.mapping/" }
143143

144144
---
145145
"match on overwritten column":
@@ -153,7 +153,7 @@ setup:
153153

154154
- match: { status: 400 }
155155
- match: { error.type: verification_exception }
156-
- match: { error.reason: "Found 1 problem\nline 1:78: [:] operator cannot operate on [content], which is not a field from an index mapping" }
156+
- match: { error.reason: "/operator.cannot.operate.on.\\[content\\],.which.is.not.a.field.from.an.index.mapping/" }
157157

158158
---
159159
"match after stats":
@@ -167,7 +167,7 @@ setup:
167167

168168
- match: { status: 400 }
169169
- match: { error.type: verification_exception }
170-
- match: { error.reason: "Found 1 problem\nline 1:36: Unknown column [content], did you mean [count(*)]?" }
170+
- match: { error.reason: "/Unknown.column.\\[content\\]/" }
171171

172172
---
173173
"match with disjunctions":
@@ -199,4 +199,4 @@ setup:
199199

200200
- match: { status: 400 }
201201
- match: { error.type: verification_exception }
202-
- match: { error.reason: "Found 1 problem\nline 1:34: [:] operator is only supported in WHERE commands" }
202+
- match: { error.reason: "/operator.is.only.supported.in.WHERE.commands/" }

0 commit comments

Comments
 (0)