Count Documents (Azure Cognitive Search REST API)
The Count Documents operation retrieves a count of the number of documents in a search index. The $count
syntax is part of the OData protocol.
GET https://[service name].search.windows.net/indexes/[index name]/docs/$count?api-version=[api-version]
Content-Type: application/json
api-key: [admin or query key]
URI Parameters
Parameter | Description |
---|---|
service name | Required. Set this to the unique, user-defined name of your search service. |
index name | Required. The [index name] in the request URI tells the service to return a count of all items in the docs collection of the specified index. |
api-version | Required. The current stable version is api-version=2020-06-30 . See API versions for more versions. |
Request Headers
The following table describes the required and optional request headers.
Fields | Description |
---|---|
Content-Type | Required. Set this to application/json |
api-key | Optional if you're using Azure roles, otherwise a key is required. An api-key is a unique, system-generated string that authenticates the request to your search service. The Count Documents request can specify either an admin key or query key for the api-key . See Connect to Cognitive Search using key authentication for details. |
You can get the api-key value from your service dashboard in the Azure portal. For more information, see Find existing keys.
Request Body
None.
Response
Status Code: 200 OK is returned for a successful response.
The response body contains the count value as an integer formatted in plain text.
See also
Azure Cognitive Search REST APIs
HTTP status codes
OData Expression Syntax for Azure Cognitive Search
Search results page