Skip to content

Commit c17e3a9

Browse files
[DOCS] Update sort examples to avoid using _id field (#11202)
* [DOCS] Update sort examples to avoid using _id field Updates sorting documentation to avoid using the _id field in examples and adds a note linking to the ID field type documentation where the limitations are explained in detail. Improves consistency with other documentation pages and best practices. Signed-off-by: Marcus V. Ximenes <marcus@marcusvinicius.info> * Update _search-plugins/searching-data/sort.md Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> --------- Signed-off-by: Marcus V. Ximenes <marcus@marcusvinicius.info> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com>
1 parent ee84854 commit c17e3a9

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

_search-plugins/searching-data/paginate.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Because open search contexts consume a lot of memory, we suggest you don't use t
159159

160160
The `search_after` parameter provides a live cursor that uses the previous page's results to obtain the next page's results. It is similar to the `scroll` operation in that it is meant to scroll many queries in parallel. You can use `search_after` only when sorting is applied.
161161

162-
For example, the following query sorts all lines from the play "Hamlet" by the speech number and then the ID and retrieves the first three results:
162+
For example, the following query sorts all lines from the play "Hamlet" by the speech number and then the line ID and retrieves the first three results:
163163

164164
```json
165165
GET shakespeare/_search
@@ -172,7 +172,7 @@ GET shakespeare/_search
172172
},
173173
"sort": [
174174
{ "speech_number": "asc" },
175-
{ "_id": "asc" }
175+
{ "line_id": "asc" }
176176
]
177177
}
178178
```
@@ -211,7 +211,7 @@ The response contains the `sort` array of values for each document:
211211
},
212212
"sort" : [
213213
1,
214-
"32435"
214+
32436
215215
]
216216
},
217217
{
@@ -229,7 +229,7 @@ The response contains the `sort` array of values for each document:
229229
},
230230
"sort" : [
231231
1,
232-
"32634"
232+
32635
233233
]
234234
},
235235
{
@@ -247,7 +247,7 @@ The response contains the `sort` array of values for each document:
247247
},
248248
"sort" : [
249249
1,
250-
"32635"
250+
32636
251251
]
252252
}
253253
]
@@ -266,10 +266,10 @@ GET shakespeare/_search
266266
"play_name": "Hamlet"
267267
}
268268
},
269-
"search_after": [ 1, "32635"],
269+
"search_after": [ 1, 32636],
270270
"sort": [
271271
{ "speech_number": "asc" },
272-
{ "_id": "asc" }
272+
{ "line_id": "asc" }
273273
]
274274
}
275275
```

_search-plugins/searching-data/sort.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,4 +879,7 @@ For each document, the sorting distance is calculated as the minimum, maximum, o
879879

880880
## Performance considerations
881881

882-
Sorted field values are loaded into memory for sorting. Therefore, for minimum overhead we recommend mapping [numeric types]({{site.url}}{{site.baseurl}}/opensearch/supported-field-types/numeric) to the smallest acceptable types, like `short`, `integer`, and `float`. [String types]({{site.url}}{{site.baseurl}}/opensearch/supported-field-types/string) should not have the sorted field analyzed or tokenized.
882+
Sorted field values are loaded into memory for sorting. Therefore, for minimum overhead we recommend mapping [numeric types]({{site.url}}{{site.baseurl}}/opensearch/supported-field-types/numeric) to the smallest acceptable types, like `short`, `integer`, and `float`. [String types]({{site.url}}{{site.baseurl}}/opensearch/supported-field-types/string) should not have the sorted field analyzed or tokenized.
883+
884+
The `_id` field is restricted from use in sorting operations. If you need to sort by document ID, consider duplicating the ID value into another field with `doc_values` enabled. For more information about `_id` field limitations, see [ID field type]({{site.url}}{{site.baseurl}}/field-types/metadata-fields/id/).
885+
{: .note}

0 commit comments

Comments
 (0)