Count Documents (Azure AI Search REST API)

Important

This API reference is for a legacy version. See Data plane REST operations for updated reference documentation. Use the filter on the top left to select a version.

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 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. See API versions for a list of supported versions.

Request Headers

The following table describes the required and optional request headers.

Fields Description
Content-Type Required. Set to application/json
api-key Optional if you're using Azure roles, otherwise a key is required. The Count Documents request can specify either an admin key or query key for the api-key. See Connect to Azure AI Search using key authentication for details.

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 AI Search REST APIs
HTTP status codes
OData Expression Syntax for Azure AI Search
Search results