You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[DOC-12432] Document Usage of {"ctl": { "validate" : true }, } for Search Queries (#302)
* [DOC-12432] Clarifying search_after and search_before behaviour, along with sorting and general pagination tips.
Adding documentation on the new validate object - in search-request-params and as examples in the simple-search topics.
Adding query results to the example in the REST API topic, and expanding on what those results mean.
Fixing error in field path in the example full-request.
* Add 7.6.4 version labels for validate property
---------
Co-authored-by: Sarah Welton <[email protected]>
Copy file name to clipboardExpand all lines: modules/search/pages/search-request-params.adoc
+3-48Lines changed: 3 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,18 +49,16 @@ Set the total number of results to return for a single page of search results.
49
49
50
50
If you provide both the `size` and `limit` properties, the Search Service uses the `size` value.
51
51
52
-
<<<<<<< HEAD
53
52
The Search Service returns the `size` number of results:
54
53
55
54
* Starting at the offset in the `from` or `offset` property.
56
55
* Starting from the key specified in the <<search_after,search_after property>>.
57
56
* Starting backward from the key specified in the <<search_before,search_before property>>.
58
57
59
58
The `size` property is added by default to all Search requests, if not otherwise specified, with a value of `10`.
60
-
=======
59
+
61
60
If you do not provide a `from`, `size`, or other pagination settings in your query, the Search Service defaults to a `size` value of `10` and a `from` value of `0`.
62
61
This means the Search Service does not offset results, and returns the first `10` matches to your query.
63
-
>>>>>>> 1385772 ([DOC-10997] Fold in information from fts-pagination to prepare for deleting the page from builds. (#298))
64
62
65
63
|from/offset |Integer |No a|
66
64
@@ -69,13 +67,10 @@ Set an offset value to change where pagination starts for search results, based
69
67
For example, if you set a `size` value of `5` and a `from` value of `10`, the Search query returns results 11 through 15 on a page.
70
68
71
69
If you provide both the `from` and `offset` properties, the Search Service uses the `from` value.
72
-
73
-
<<<<<<< HEAD
74
-
The `from` property is added by default to all Search requests, if not otherwise specified, with a value of `0`.
75
-
=======
76
70
If you do not provide a `from`, `size`, or other pagination settings in your query, the Search Service defaults to a `size` value of `10` and a `from` value of `0`.
77
71
This means the Search Service does not offset results, and returns the first `10` matches to your query.
78
-
>>>>>>> 1385772 ([DOC-10997] Fold in information from fts-pagination to prepare for deleting the page from builds. (#298))
72
+
73
+
The `from` property is added by default to all Search requests, if not otherwise specified, with a value of `0`.
79
74
80
75
|highlight |Object |No a|
81
76
@@ -107,11 +102,7 @@ To create an explanation for a search result's score in search results, set `exp
107
102
108
103
To turn off explanations for search result scoring, set `explain` to `false`.
109
104
110
-
<<<<<<< HEAD
111
105
|[[sort_arr]]sort |Array |No a|
112
-
=======
113
-
|[[sort-array]]sort |Array |No a|
114
-
>>>>>>> 1385772 ([DOC-10997] Fold in information from fts-pagination to prepare for deleting the page from builds. (#298))
115
106
116
107
Contains an array of strings or JSON objects to set how to sort search results.
117
108
By default, the Search Service sorts results based on score values, from highest to lowest.
@@ -141,7 +132,6 @@ To turn on document relevancy scoring in search results, remove the `score` prop
141
132
142
133
|[[search_after]]search_after |Array |No a|
143
134
144
-
<<<<<<< HEAD
145
135
NOTE: If you use `search_after` in a search request, you can't use `search_before`.
146
136
Both properties are included in the example code to show the correct syntax.
147
137
@@ -154,27 +144,12 @@ You cannot use `search_after` with numbers or other field data types - if your `
154
144
Only result relevancy score values can be entered as strings in the array.
155
145
156
146
The Search Service starts search result pagination after the document with the values you provide in the array.
157
-
=======
158
-
NOTE: If you use `search_after` in a search request, you cannot use `search_before`. Both properties are included in the example code to show the correct syntax.
159
-
160
-
Use `search_after` with `from/offset` and `sort` to control pagination in search results.
161
147
162
148
For example, if you had a set of 10 documents to sort based on `_id` values of 1-10, with `from` set to `2` and `search_after` set to `8`, documents 9-10 appear on the same page.
163
149
164
-
You must give a value for each string or JSON object in the `sort` array to the `search_after` array.
165
-
The Search Service starts search result pagination after the document with those values.
166
-
167
-
You must provide the values in the same order that they appear in the `sort` array.
168
-
Your `sort` array must force a total order on your search results.
169
-
>>>>>>> 1385772 ([DOC-10997] Fold in information from fts-pagination to prepare for deleting the page from builds. (#298))
170
-
171
-
Use `search_after` to make the memory requirements of deeper page searches more manageable, when compared to using only `from/offset`.
172
-
`search_after` lets you start your search results from a specific result, rather than needing to process a number of search results to skip.
173
-
174
150
To reduce the resource costs of deeper pagination on your Search queries, try to always include your document ID values as the final sort criteria in your <<sort_arr,sort array>>.
175
151
Set the `search_after` property to include the values from the last result on your previous page of search results to effectively paginate.
176
152
177
-
<<<<<<< HEAD
178
153
|[[search_before]]search_before |Array |No a|
179
154
180
155
NOTE: If you use `search_before` in a search request, you can't use `search_after`.
@@ -194,22 +169,6 @@ For example, if you had a set of 10 documents to sort based on `_id` values of 1
194
169
195
170
To reduce the resource costs of deeper pagination on your Search queries, try to always include your document ID values as the final sort criteria in your <<sort_arr,sort array>>.
196
171
Set the `search_before` property to include the values from the last result on your previous page of search results to effectively paginate.
197
-
=======
198
-
NOTE: If you use `search_before` in a search request, you cannot use `search_after`. Both properties are included in the example code to show the correct syntax.
199
-
200
-
Use `search_before` with `from/offset` and `sort` to control pagination in search results.
201
-
202
-
For example, if you had a set of 10 documents to sort based on `_id` values of 1-10, with `from` set to `2` and `search_before` set to `8`, documents 2-6 appear on the same page.
203
-
204
-
You must give a value for each string or JSON object in the `sort` array to the `search_before` array.
205
-
The Search Service starts search result pagination before the document with those values.
206
-
207
-
You must provide the values in the same order that they appear in the `sort` array.
208
-
Your `sort` array must force a total order on your search results.
209
-
210
-
Use `search_before` to make the memory requirements of deeper page searches more manageable, when compared to using only `from/offset`.
211
-
`search_before` lets you start your search results back from a specific result, rather than needing to process a number of search results to skip.
212
-
>>>>>>> 1385772 ([DOC-10997] Fold in information from fts-pagination to prepare for deleting the page from builds. (#298))
213
172
214
173
|[[collections]]collections |Array |No |Contains an array of strings that specify the collections where you want to run the query.
215
174
@@ -2290,12 +2249,8 @@ The following `sort` object orders search results by the values in `field1`, the
This means that if 2 documents have the same value in `field1`, then the Search Service will sort them again based on their `field2` values.
2295
2253
If they have the same value in `field2`, then sorting will happen again based on each document's score, and then finally the documents' ID values.
2296
-
=======
2297
-
TIP: For the best results with sorting and page navigation in search results, always include your document ID values (`_id` or `-_id`) as the final sort criteria in your `sort` object.
2298
-
>>>>>>> 1385772 ([DOC-10997] Fold in information from fts-pagination to prepare for deleting the page from builds. (#298))
2299
2254
2300
2255
The `sort` object can contain the following string values:
0 commit comments