Skip to content

Commit

Permalink
[DOCS] document replacement for search exists
Browse files Browse the repository at this point in the history
Relates to elastic#13910
Closes elastic#14393
  • Loading branch information
javanna committed Nov 9, 2015
1 parent 10ddd69 commit ca980b7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
40 changes: 40 additions & 0 deletions docs/reference/search/request-body.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,46 @@ parameter named `source`.
Both HTTP GET and HTTP POST can be used to execute search with body. Since not
all clients support GET with body, POST is allowed as well.

[float]
=== Fast check for any matching docs

In case we only want to know if there are any documents matching a
specific query, we can set the `size` to `0` to indicate that we are not
interested in the search results. Also we can set `terminate_after` to `1`
to indicate that the query execution can be terminated whenever the first
matching document was found (per shard).

[source,js]
--------------------------------------------------
$ curl -XGET 'http://localhost:9200/_search?q=tag:wow&size=0&terminate_after=1'
--------------------------------------------------

The response will not contain any hits as the `size` was set to `0`. The
`hits.total` will be either equal to `0`, indicating that there were no
matching documents, or greater than `0` meaning that there were at least
as many documents matching the query when it was early terminated.
Also if the query was terminated early, the `terminated_early` flag will
be set to `true` in the response.

[source,js]
--------------------------------------------------
{
"took": 3,
"timed_out": false,
"terminated_early": true,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0,
"hits": []
}
}
--------------------------------------------------


include::request/query.asciidoc[]

Expand Down
1 change: 0 additions & 1 deletion docs/reference/search/search.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@ Or even search across all indices and all types:
--------------------------------------------------
$ curl -XGET 'http://localhost:9200/_search?q=tag:wow'
--------------------------------------------------

0 comments on commit ca980b7

Please sign in to comment.