Skip to content

Commit ca980b7

Browse files
committed
[DOCS] document replacement for search exists
Relates to #13910 Closes #14393
1 parent 10ddd69 commit ca980b7

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

docs/reference/search/request-body.asciidoc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,46 @@ parameter named `source`.
9494
Both HTTP GET and HTTP POST can be used to execute search with body. Since not
9595
all clients support GET with body, POST is allowed as well.
9696

97+
[float]
98+
=== Fast check for any matching docs
99+
100+
In case we only want to know if there are any documents matching a
101+
specific query, we can set the `size` to `0` to indicate that we are not
102+
interested in the search results. Also we can set `terminate_after` to `1`
103+
to indicate that the query execution can be terminated whenever the first
104+
matching document was found (per shard).
105+
106+
[source,js]
107+
--------------------------------------------------
108+
$ curl -XGET 'http://localhost:9200/_search?q=tag:wow&size=0&terminate_after=1'
109+
--------------------------------------------------
110+
111+
The response will not contain any hits as the `size` was set to `0`. The
112+
`hits.total` will be either equal to `0`, indicating that there were no
113+
matching documents, or greater than `0` meaning that there were at least
114+
as many documents matching the query when it was early terminated.
115+
Also if the query was terminated early, the `terminated_early` flag will
116+
be set to `true` in the response.
117+
118+
[source,js]
119+
--------------------------------------------------
120+
{
121+
"took": 3,
122+
"timed_out": false,
123+
"terminated_early": true,
124+
"_shards": {
125+
"total": 1,
126+
"successful": 1,
127+
"failed": 0
128+
},
129+
"hits": {
130+
"total": 1,
131+
"max_score": 0,
132+
"hits": []
133+
}
134+
}
135+
--------------------------------------------------
136+
97137

98138
include::request/query.asciidoc[]
99139

docs/reference/search/search.asciidoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,3 @@ Or even search across all indices and all types:
4949
--------------------------------------------------
5050
$ curl -XGET 'http://localhost:9200/_search?q=tag:wow'
5151
--------------------------------------------------
52-

0 commit comments

Comments
 (0)