| « PreviousNext » | |
![]() ![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
The document service API is a REST-style API that has a single resource, documents/batch. You submit documents/batch requests to your domain's unique document service endpoint to add, update, or delete documents. A documents/batch request is an HTTP request, as defined by RFC 2616. All documents/batch requests must be submitted using HTTP POST.
You must specify the Amazon CloudSearch API version in every document service request. The current Amazon CloudSearch API version is 2011-02-01. The version number precedes the resource name in the request, for example POST /2011-02-01/documents/batch.
Access to a search domain's document service is restricted by IP address so that only authorized hosts can submit document changes. By default, your search domain will not accept document service
requests from any IP addresses. You must authorize specific IP addresses or address ranges before you can submit documents through the command line tools or APIs. You can configure access policies from the Amazon CloudSearch console, using the cs-configure-access-policies command, or with the UpdateServiceAccessPolicies configuration action.
A documents/batch request must include the following headers:
Content-Length—the length of the request body, in bytes.
Content-Type—the type of data in the request body, application/json or application/xml.
Host—your domain's document service endpoint.
By default, the response to a documents/batch request is returned in JSON. You can set the Accept
header to application/xml if you want an XML response.
The body of a documents/batch request contains a JSON or XML description of the document operations you want to perform. This description conforms to the Search Data Format (SDF). For more information about SDF, see Preparing Your Data for Amazon CloudSearch.
POST /2011-02-01/documents/batch HTTP/1.1
Accept: application/json
Content-Length: 1176
Content-Type: application/json
Host: doc.imdb-movies-rr2f34ofg56xneuemujamut52i.us-east-1.cloudsearch.amazonaws.com
[
{ "type": "add",
"id": "tt0484562",
"version": 1337648735,
"lang": "en",
"fields": {
"title": "The Seeker: The Dark Is Rising",
"director": "Cunningham, David L.",
"genre": ["Adventure","Drama","Fantasy","Thriller"],
"actor": ["McShane, Ian","Eccleston, Christopher","Conroy, Frances"] }
}
},
{ "type": "delete",
"id": "tt0434409",
"version": 1337648735
}
]