Skip to content

[DOCS] document replacement for search exists #14393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
--------------------------------------------------