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
+53-12Lines changed: 53 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,14 @@ 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
+
The Search Service returns the `size` number of results:
53
+
54
+
* Starting at the offset in the `from` or `offset` property.
55
+
* Starting from the key specified in the <<search_after,search_after property>>.
56
+
* Starting backward from the key specified in the <<search_before,search_before property>>.
57
+
58
+
The `size` property is added by default to all Search requests, if not otherwise specified, with a value of `10`.
59
+
52
60
|from/offset |Integer |No a|
53
61
54
62
Set an offset value to change where pagination starts for search results, based on the Search query's <<sort,>>.
@@ -57,6 +65,8 @@ For example, if you set a `size` value of `5` and a `from` value of `10`, the Se
57
65
58
66
If you provide both the `from` and `offset` properties, the Search Service uses the `from` value.
59
67
68
+
The `from` property is added by default to all Search requests, if not otherwise specified, with a value of `0`.
69
+
60
70
|highlight |Object |No a|
61
71
62
72
Contains properties to control search result highlighting.
@@ -87,7 +97,7 @@ To create an explanation for a search result's score in search results, set `exp
87
97
88
98
To turn off explanations for search result scoring, set `explain` to `false`.
89
99
90
-
|sort |Array |No a|
100
+
|[[sort_arr]]sort |Array |No a|
91
101
92
102
Contains an array of strings or JSON objects to set how to sort search results.
93
103
@@ -114,31 +124,45 @@ To turn off document relevancy scoring in search results, set `score` to `none`.
114
124
115
125
To turn on document relevancy scoring in search results, remove the `score` property.
116
126
117
-
|search_after |Array |No a|
127
+
|[[search_after]]search_after |Array |No a|
118
128
119
-
NOTE: If you use `search_after` in a search request, you can't use `search_before`. Both properties are included in the example code to show the correct syntax.
129
+
NOTE: If you use `search_after` in a search request, you can't use `search_before`.
130
+
Both properties are included in the example code to show the correct syntax.
120
131
121
132
Use `search_after` with `from/offset` and `sort` to control pagination in search results.
122
133
123
-
Give a value for each string or JSON object in the `sort` array to the `search_after` array.
124
-
The Search Service starts search result pagination after the document with those values.
134
+
Give a value for each string or JSON object in the <<sort_arr,sort array>> to the `search_after` array.
135
+
You must provide the values in the same order that they appear in the <<sort_arr,sort array>>.
136
+
Values in the `search_after` array must be strings.
137
+
You cannot use `search_after` with numbers or other field data types - if your `sort` array includes fields with a `date` or `number` type, you cannot use `search_after`.
138
+
Only result relevancy score values can be entered as strings in the array.
125
139
126
-
You must provide the values in the same order that they appear in the `sort`array.
140
+
The Search Service starts search result pagination after the document with the values you provide in the array.
127
141
128
142
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.
129
143
130
-
|search_before |Array |No a|
144
+
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>>.
145
+
Set the `search_after` property to include the values from the last result on your previous page of search results to effectively paginate.
131
146
132
-
NOTE: If you use `search_before` in a search request, you can't use `search_after`. Both properties are included in the example code to show the correct syntax.
147
+
|[[search_before]]search_before |Array |No a|
148
+
149
+
NOTE: If you use `search_before` in a search request, you can't use `search_after`.
150
+
Both properties are included in the example code to show the correct syntax.
133
151
134
152
Use `search_before` with `from/offset` and `sort` to control pagination in search results.
135
153
136
154
Give a value for each string or JSON object in the `sort` array to the `search_before` array.
137
-
The Search Service starts search result pagination before the document with those values.
155
+
You must provide the values in the same order that they appear in the `sort` array.
156
+
Values in the `search_before` array must be strings.
157
+
You cannot use `search_before` with numbers or other field data types - if your `sort` array includes fields with a `date` or `number` type, you cannot use `search_before`.
158
+
Only result relevancy score values can be entered as strings in the array.
159
+
160
+
The Search Service starts search result pagination before the document with the values you provide in the array.
138
161
139
-
You must provide the values in the same order that they appear in the `sort` array.
162
+
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.
140
163
141
-
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.
164
+
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>>.
165
+
Set the `search_before` property to include the values from the last result on your previous page of search results to effectively paginate.
142
166
143
167
|[[collections]]collections |Array |No |Contains an array of strings that specify the collections where you want to run the query.
144
168
@@ -1889,7 +1913,9 @@ The Search Service uses a consistency vector to synchronize the last document wr
The `ctl` object contains the following properties:
1916
+
In Couchbase Server 7.6.4 and later, you can also use the `ctl` object with the `validate` property to add an extra check to your queries and get help troubleshooting when a query does not return results.
1917
+
1918
+
The `ctl` object can contain the following properties:
1893
1919
1894
1920
[cols="1,1,1,4"]
1895
1921
|====
@@ -1908,6 +1934,18 @@ An object that contains a `vectors` object and the `level` and `results` propert
1908
1934
1909
1935
For more information, see <<consistency,>>.
1910
1936
1937
+
|[[validate]]validate |Boolean |No a|
1938
+
1939
+
[.status]#Couchbase Server 7.6.4#
1940
+
1941
+
Add the `validate` property with a value of `true` to add extra validation checks to your Search query.
1942
+
1943
+
For example, the Search Service can tell you through the Web Console or the REST API that a field in your Search query is not in your Search index:
1944
+
1945
+
----
1946
+
err: query_validate: field not indexed, field: ratings.Cleanliness, type: number
1947
+
----
1948
+
1911
1949
|====
1912
1950
1913
1951
[#consistency]
@@ -2166,6 +2204,9 @@ The following `sort` object orders search results by the values in `field1`, the
0 commit comments