Documents - Index
Sends a batch of document write actions to the index.
POST {endpoint}/indexes('{indexName}')/docs/search.index?api-version=2024-03-01-Preview
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
endpoint
|
path | True |
string |
The endpoint URL of the search service. |
index
|
path | True |
string |
The name of the index. |
api-version
|
query | True |
string |
Client Api Version. |
Request Header
Name | Required | Type | Description |
---|---|---|---|
x-ms-client-request-id |
string uuid |
The tracking ID sent with the request to help with debugging. |
Request Body
Name | Required | Type | Description |
---|---|---|---|
value | True |
The actions in the batch. |
Responses
Name | Type | Description |
---|---|---|
200 OK |
Response containing the status of operations for all actions in the batch. |
|
Other Status Codes |
Response containing the status of operations for all actions in the batch. |
|
Other Status Codes |
Error response. |
Examples
SearchIndexIndexDocuments
Sample request
POST https://myservice.search.windows.net/indexes('myindex')/docs/search.index?api-version=2024-03-01-Preview
{
"value": [
{
"@search.action": "upload",
"docId": "1",
"title": "Fancy Stay",
"description": "Best hotel in town"
},
{
"@search.action": "merge",
"docId": "2",
"title": "Roach Motel"
},
{
"@search.action": "mergeOrUpload",
"docId": "3",
"title": "Econo Motel"
},
{
"@search.action": "delete",
"docId": "4"
}
]
}
Sample response
{
"value": [
{
"key": "1",
"status": true,
"errorMessage": null,
"statusCode": 201
},
{
"key": "2",
"status": true,
"errorMessage": null,
"statusCode": 200
},
{
"key": "3",
"status": true,
"errorMessage": null,
"statusCode": 200
},
{
"key": "4",
"status": true,
"errorMessage": null,
"statusCode": 200
}
]
}
{
"value": [
{
"key": "1",
"status": true,
"errorMessage": null,
"statusCode": 200
},
{
"key": "2",
"status": false,
"errorMessage": "Document not found.",
"statusCode": 404
},
{
"key": "3",
"status": true,
"errorMessage": null,
"statusCode": 200
},
{
"key": "4",
"status": true,
"errorMessage": null,
"statusCode": 200
}
]
}
Definitions
Name | Description |
---|---|
Error |
The resource management error additional info. |
Error |
The error detail. |
Error |
Error response |
Index |
Represents an index action that operates on a document. |
Index |
The operation to perform on a document in an indexing batch. |
Index |
Contains a batch of document write actions to send to the index. |
Index |
Response containing the status of operations for all documents in the indexing request. |
Indexing |
Status of an indexing operation for a single document. |
ErrorAdditionalInfo
The resource management error additional info.
Name | Type | Description |
---|---|---|
info |
object |
The additional info. |
type |
string |
The additional info type. |
ErrorDetail
The error detail.
Name | Type | Description |
---|---|---|
additionalInfo |
The error additional info. |
|
code |
string |
The error code. |
details |
The error details. |
|
message |
string |
The error message. |
target |
string |
The error target. |
ErrorResponse
Error response
Name | Type | Description |
---|---|---|
error |
The error object. |
IndexAction
Represents an index action that operates on a document.
Name | Type | Description |
---|---|---|
@search.action |
The operation to perform on a document in an indexing batch. |
IndexActionType
The operation to perform on a document in an indexing batch.
Name | Type | Description |
---|---|---|
delete |
string |
Removes the specified document from the index. Any field you specify in a delete operation other than the key field will be ignored. If you want to remove an individual field from a document, use merge instead and set the field explicitly to null. |
merge |
string |
Merges the specified field values with an existing document. If the document does not exist, the merge will fail. Any field you specify in a merge will replace the existing field in the document. This also applies to collections of primitive and complex types. |
mergeOrUpload |
string |
Behaves like merge if a document with the given key already exists in the index. If the document does not exist, it behaves like upload with a new document. |
upload |
string |
Inserts the document into the index if it is new and updates it if it exists. All fields are replaced in the update case. |
IndexBatch
Contains a batch of document write actions to send to the index.
Name | Type | Description |
---|---|---|
value |
The actions in the batch. |
IndexDocumentsResult
Response containing the status of operations for all documents in the indexing request.
Name | Type | Description |
---|---|---|
value |
The list of status information for each document in the indexing request. |
IndexingResult
Status of an indexing operation for a single document.
Name | Type | Description |
---|---|---|
errorMessage |
string |
The error message explaining why the indexing operation failed for the document identified by the key; null if indexing succeeded. |
key |
string |
The key of a document that was in the indexing request. |
status |
boolean |
A value indicating whether the indexing operation succeeded for the document identified by the key. |
statusCode |
integer |
The status code of the indexing operation. Possible values include: 200 for a successful update or delete, 201 for successful document creation, 400 for a malformed input document, 404 for document not found, 409 for a version conflict, 422 when the index is temporarily unavailable, or 503 for when the service is too busy. |