Using the Batch APIs

To send batches of up to 25 documents, you can use the Amazon Comprehend batch operations.
Calling
a batch operation is identical to calling the single document APIs for each document
in
the request. Using the batch APIs can result in better performance for you applications.
For more information, see .

Batch Processing With the SDK for Java

The following sample program shows how to use the operation
with the SDK for Java. The response from the server contains a BatchDetectEntitiesItemResult object for each document
that was successfully processed. If there is an error processing a document there
will be a record in the error list in the response. The example gets each of the
documents with an error and resends them.

Batch Processing With the AWS CLI

These examples show how to use the batch API operations using the AWS Command Line
Interface. All
of the operations except BatchDetectDominantLanguage use the following
JSON file called process.json as input. For that operation the
LanguageCode entity is not included.

The third document in the JSON file ("$$$$$$$$") will cause an error
during batch processing. It is included so that the operations will include a BatchItemError in the
response.

Copy

{
"LanguageCode": "en",
"TextList": [
"I have been living in Seattle for almost 4 years",
"It is raining today in Seattle",
"$$$$$$$$"
]
}

The examples are formatted for Unix, Linux, and macOS. For Windows, replace the
backslash (\) Unix continuation character at the end of each line with a caret
(^).

Detect Entities Using a Batch (AWS CLI)

Use the BatchDetectEntities operation to find the entities
present in a batch of documents. For more information about entities, see Detecting Entities. The following AWS CLI
command calls the BatchDetectEntities operation.