Skip to content

Commit f6ffa00

Browse files
committed
[DOCS] Reformats search API (#45786)
Co-Authored-By: James Rodewig <[email protected]>
1 parent 5e44e69 commit f6ffa00

File tree

1 file changed

+215
-8
lines changed

1 file changed

+215
-8
lines changed

docs/reference/search/search.asciidoc

Lines changed: 215 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,225 @@
11
[[search-search]]
22
=== Search
33

4-
The search API allows you to execute a search query and get back search hits
5-
that match the query. The query can either be provided using a simple
4+
Returns search hits that match the query defined in the request.
5+
6+
[source,js]
7+
--------------------------------------------------
8+
GET /twitter/_search?q=user:kimchy
9+
--------------------------------------------------
10+
// CONSOLE
11+
// TEST[setup:twitter]
12+
13+
14+
[[search-search-api-request]]
15+
==== {api-request-title}
16+
17+
`GET /{index}/_search` +
18+
19+
`GET /all/_search`
20+
21+
22+
[[search-search-api-desc]]
23+
==== {api-description-title}
24+
25+
Allows you to execute a search query and get back search hits that match the
26+
query. The query can either be provided using a simple
627
<<search-uri-request,query string as a parameter>>, or using a
728
<<search-request-body,request body>>.
829

30+
[[search-partial-responses]]
31+
===== Partial responses
32+
33+
To ensure fast responses, the search API will respond with partial results if
34+
one or more shards fail. See <<shard-failures, Shard failures>> for more
35+
information.
36+
37+
[[search-search-api-path-params]]
38+
==== {api-path-parms-title}
39+
40+
include::{docdir}/rest-api/common-parms.asciidoc[tag=index]
41+
42+
43+
[[search-search-api-query-params]]
44+
==== {api-query-parms-title}
45+
46+
include::{docdir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
47+
48+
`allow_partial_search_results`::
49+
(Optional, boolean) Indicates if an error should be returned if there is a
50+
partial search failure or timeout. Defaults to `true`.
51+
52+
`analyzer`::
53+
(Optional, string) Defines the analyzer to use for the query string.
54+
55+
`analyze_wildcard`::
56+
(Optional, boolean) If `true`, wildcard and prefix queries will also be
57+
analyzed. Defaults to `false`.
58+
59+
`batched_reduce_size`::
60+
(Optional, integer) The number of shard results that should be reduced at once
61+
on the coordinating node. This value should be used as a protection mechanism
62+
to reduce the memory overhead per search request if the potential number of
63+
shards in the request can be large. Defaults to `512`.
64+
65+
`ccs_minimize_roundtrips`::
66+
(Optional, boolean) Indicates whether network round-trips should be minimized
67+
as part of cross-cluster search requests execution. Defaults to `true`.
68+
69+
`default_operator`::
70+
(Optional, string) The default operator for query string query (AND or OR).
71+
Defaults to `OR`.
72+
73+
`df`::
74+
(Optional, string) Defines the field to use as default where no field prefix
75+
is given in the query string.
76+
77+
`docvalue_fields`::
78+
(Optional, string) A comma-separated list of fields to return as the docvalue
79+
representation of a field for each hit.
80+
81+
include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
82+
+
83+
Defaults to `open`.
84+
85+
`explain`::
86+
(Optional, boolean) If `true`, returns detailed information about score
87+
computation as part of a hit. Defaults to `false`.
88+
89+
`from`::
90+
(Optional, integer) Defines the starting offset. Defaults to `0`.
91+
92+
`ignore_throttled`::
93+
(Optional, boolean) If `true`, concrete, expanded or aliased indices will be
94+
ignored when throttled. Defaults to `false`.
95+
96+
include::{docdir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
97+
98+
`lenient`::
99+
(Optional, boolean) If `true`, format-based query failures (such as
100+
providing text to a numeric field) will be ignored. Defaults to `false`.
101+
102+
`max_concurrent_shard_requests`::
103+
(Optional, integer) Defines the number of concurrent shard requests per node
104+
this search executes concurrently. This value should be used to limit the
105+
impact of the search on the cluster in order to limit the number of concurrent
106+
shard requests. Defaults to `5`.
107+
108+
`pre_filter_shard_size`::
109+
(Optional, integer) Defines a threshold that enforces a pre-filter roundtrip
110+
to prefilter search shards based on query rewriting if the number of shards
111+
the search request expands to exceeds the threshold. This filter roundtrip can
112+
limit the number of shards significantly if for instance a shard can not match
113+
any documents based on it's rewrite method ie. if date filters are mandatory
114+
to match but the shard bounds and the query are disjoint. Defaults to `128`.
115+
116+
`preference`::
117+
(Optional, string) Specifies the node or shard the operation should be
118+
performed on. Random by default.
119+
120+
`q`::
121+
(Optional, string) Query in the Lucene query string syntax.
122+
123+
`request_cache`::
124+
(Optional, boolean) If `true`, request cache will be used for this request.
125+
Defaults to index level settings.
126+
127+
`rest_total_hits_as_int`::
128+
(Optional, boolean) Indicates whether hits.total should be rendered as an
129+
integer or an object in the rest search response. Defaults to `false`.
130+
131+
`routing`::
132+
(Optional, <<time-units, time units>>) Specifies how long a consistent view of
133+
the index should be maintained for scrolled search.
134+
135+
`search_type`::
136+
(Optional, string) Defines the type of the search operation. Available
137+
options:
138+
* `query_then_fetch`
139+
* `dfs_query_then_fetch`
140+
141+
`seq_no_primary_term`::
142+
(Optional, boolean) If `true`, returns sequence number and primary term of the
143+
last modification of each hit.
144+
145+
`size`::
146+
(Optional, integer) Defines the number of hits to return. Defaults to `10`.
147+
148+
`sort`::
149+
(Optional, string) A comma-separated list of <field>:<direction> pairs.
150+
151+
`_source`::
152+
(Optional, string) True or false to return the `_source` field or not, or a
153+
list of fields to return.
154+
155+
`_source_excludes`::
156+
(Optional, string) A list of fields to exclude from the returned `_source`
157+
field.
158+
159+
`_source_includes`::
160+
(Optional, string) A list of fields to extract and return from the `_source`
161+
field.
162+
163+
`stats`::
164+
(Optional, string) Specific `tag` of the request for logging and statistical
165+
purposes.
166+
167+
`stored_fields`::
168+
(Optional, string) A comma-separated list of stored fields to return as part
169+
of a hit.
170+
171+
`suggest_field`::
172+
(Optional, string) Specifies which field to use for suggestions.
173+
174+
`suggest_mode`::
175+
(Optional, string) Specifies suggest mode. Defaults to `missing`. Available
176+
options:
177+
* `always`
178+
* `missing`
179+
* `popular`
180+
181+
`suggest_size`::
182+
(Optional, integer) Defines how many suggestions to return in response.
183+
184+
`suggest_text`::
185+
(Optional, string) The source text for which the suggestions should be
186+
returned.
187+
188+
`terminate_after`::
189+
(Optional, integer) The maximum number of documents to collect for each shard,
190+
upon reaching which the query execution will terminate early.
191+
192+
include::{docdir}/rest-api/common-parms.asciidoc[tag=timeout]
193+
194+
`track_scores`::
195+
(Optional, boolean) If `true`, then calculates and returns scores even if they
196+
are not used for sorting.
197+
198+
`track_total_hits`::
199+
(Optional, boolean) Indicates if the number of documents that match the query
200+
should be tracked.
201+
202+
`typed_keys`::
203+
(Optional, boolean) Specifies whether aggregation and suggester names should
204+
be prefixed by their respective types in the response.
205+
206+
`version`::
207+
(Optional, boolean) If `true`, returns document version as part of a hit.
208+
209+
210+
[[search-search-api-request-body]]
211+
==== {api-request-body-title}
212+
213+
`query`::
214+
(Optional, <<query-dsl,query object>>) Defines the search definition using the
215+
<<query-dsl,Query DSL>>.
216+
217+
218+
[[search-search-api-example]]
219+
==== {api-examples-title}
220+
9221
["float",id="search-multi-index"]
10-
==== Multi-Index
222+
===== Multi-Index
11223

12224
All search APIs can be applied across multiple indices with support for
13225
the <<multi-index,multi index syntax>>. For
@@ -38,8 +250,3 @@ GET /_all/_search?q=tag:wow
38250
---------------------------------------------------
39251
// CONSOLE
40252
// TEST[setup:twitter]
41-
42-
[float]
43-
[[search-partial-responses]]
44-
==== Partial responses
45-
To ensure fast responses, the search API will respond with partial results if one or more shards fail. See <<shard-failures, Shard failures>> for more information.

0 commit comments

Comments
 (0)