Skip to content

Commit ac62aa0

Browse files
committed
[DOCS] Count API: clarify ways to specify search query (#120564)
* Clarify query methods; other sprucing * Apply suggestions from review
1 parent faeeb31 commit ac62aa0

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

docs/reference/rest-api/common-parms.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ end::search-q[]
865865

866866
tag::query[]
867867
`query`::
868-
(Optional, <<query-dsl,query object>>) Defines the search definition using the
868+
(Optional, <<query-dsl,query object>>) Defines the search query using
869869
<<query-dsl,Query DSL>>.
870870
end::query[]
871871

docs/reference/search/count.asciidoc

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ GET /my-index-000001/_count?q=user:kimchy
1212
--------------------------------------------------
1313
// TEST[setup:my_index]
1414

15-
NOTE: The query being sent in the body must be nested in a `query` key, same as
16-
the <<search-search,search API>> works.
17-
18-
1915
[[search-count-api-request]]
2016
==== {api-request-title}
2117

@@ -33,9 +29,12 @@ or alias.
3329
==== {api-description-title}
3430

3531
The count API allows you to execute a query and get the number of matches for
36-
that query. The query can either
37-
be provided using a simple query string as a parameter, or using the
38-
<<query-dsl,Query DSL>> defined within the request body.
32+
that query. You can provide the query by either:
33+
34+
* Including the <<search-count-api-query-params,`q` query string parameter>>
35+
* Defining <<query-dsl,Query DSL>> within the <<search-count-request-body,request body>>
36+
37+
Using both returns an error.
3938

4039
The count API supports <<api-multi-index,multi-target syntax>>. You can run a single
4140
count API search across multiple data streams and indices.
@@ -86,6 +85,8 @@ include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=lenient]
8685
include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=preference]
8786

8887
include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=search-q]
88+
+
89+
NOTE: If the `q` parameter is specified, the count API does not accept a <<search-count-request-body,request body>>.
8990

9091
include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=routing]
9192

@@ -134,5 +135,5 @@ Both examples above do the same: count the number of documents in
134135
}
135136
--------------------------------------------------
136137

137-
The query is optional, and when not provided, it will use `match_all` to
138-
count all the docs.
138+
The query is optional. When no query is provided, the API uses <<query-dsl-match-all-query,`match_all`>> to
139+
count all the documents.

0 commit comments

Comments
 (0)