Submitting Document Service Requests in Amazon
We recommend using one of the AWS SDKs or the AWS CLI to submit document upload requests.The
SDKs and AWS CLI handle request signing for you and provide an easy way to perform all Amazon
CloudSearch actions.To process source documents and upload the generated JSON or XML batches
to your domain in one step, you can use the cs-import-documents command in the standalone Amazon
CloudSearch command line tools. For more information, see Processing Your Source Data (p.62).You
can also use the Amazon CloudSearch console to upload individual batches and import data from
DynamoDB or S3.
A domain's document and search endpoints remain the same for the life of the domain.You
should cache the endpoints rather than retrieving them before every upload or search request.
Querying the Amazon CloudSearch configuration service by calling aws cloudsearch
describe-domains or DescribeDomains before every request is likely to result in your
requests being throttled.
For example, the following request uploads a batch using the AWS CLI.
aws cloudsearchdomain --endpoint-url http://doc-movies-y6gelr4lv3jeu4rvoe
lunxsl2e.us-east-1.cloudsearch.amazonaws.com upload-documents --content-type
application/json --documents movie-data-2013.json
For development and testing purposes, you can allow anonymous access to your domain's document
service and submit unsigned HTTP POST requests directly to your domain's document service. In a
production environment, restrict access to your domain to specific IAM users, groups, or roles and submit
signed requests. For information about controlling access for Amazon CloudSearch, see Configuring
Access for Amazon CloudSearch (p.29). For more information about request signing, see Signing AWS
For example, the following POST request uploads a batch of documents formatted in JSON to the domain
curl -X POST --upload-file data1.json doc-movies-123456789012.us-east-1.cloud
search.amazonaws.com/2013-01-01/documents/batch --header "Content-Type: applic
This section describes the HTTP request and response messages for the documents/batch resource.
You create document batches to describe the data that you want to upload to an Amazon CloudSearch
domain. A document batch is a collection of add and delete operations that represent the documents you
want to add, update, or delete from your domain. Batches can be described in either JSON or XML. A
batch provides all of the information Amazon CloudSearch needs for indexing. Each item that you want
to be able to return as a search result (such as a product) is represented as a document—a batch is
simply a collection of add and delete requests for individual documents. Every document has a unique
ID and one or more fields that contain the data that you want to search and return in results.
To update a document, you specify an add request with the document ID of the document you want to
update. For more information, see Adding and Updating Documents in Amazon CloudSearch (p.61).
Similarly, to delete a document, you submit a delete request with the document ID of the document you
want to delete. For information about deleting documents, see Deleting Documents in Amazon
API Version 2013-01-01
Amazon CloudSearch Developer Guide
Submitting Document Service Requests