Lookup Document (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 Lookup Document operation retrieves a document from Azure AI Search. This is useful when a user clicks on a specific search result, and you want to look up specific details about that document. You can only get one document at a time. Use Search Documents to get multiple documents in a single request.
GET https://[service name].search.windows.net/indexes/[index name]/docs/key?[query parameters]
Content-Type: application/json
api-key: [admin or query key]
Alternatively, you can use the traditional OData syntax for key lookup:
GET /indexes/[index name]/docs('[key]')?[query parameters]
URI Parameters
Parameter | Description |
---|---|
service name | Required. Set this to the unique, user-defined name of your search service. |
index name | Required. The request URI specifies the name of the index to query. Query parameters are specified on the query string for GET requests and in the request body for POST requests. |
key | Required. An Edm.String value that uniquely identifies each document in the index. The key is sometimes referred to as a document ID. The value of the key is case-sensitive. For example, a document with key "abc" is distinct from a document with key "ABC". |
query parameters | A multi-part construction that includes a $select (optional) and api-version=2020-06-30 (required). For this operation, the api-version is specified as a query parameter. $select=[string] is a list of comma-separated fields to retrieve. Only fields marked as retrievable can be included in this clause. If unspecified or set to * , all fields marked as retrievable in the schema are included in the projection. |
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 and a bearer token is provided on the request, otherwise a key is required. An api-key is a unique, system-generated string that authenticates the request to your search service. Get requests for an object definition must include an api-key field set to your admin key (as opposed to a query 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.
{
field_name: field_value (fields matching the default or specified projection)
}
Examples
Lookup the document that has key '2':
GET /indexes/hotels/docs/2?api-version=2020-06-30
Lookup the document that has key '3' using OData syntax:
GET /indexes/hotels/docs('3')?api-version=2020-06-30