documents/batch XML API - Amazon CloudSearch

documents/batch XML API

XML documents/batch Requests

The body of a documents/batch request specifies the document operations you want to perform in XML. For example:

<batch> <add id="tt0484562"> <field name="title">The Seeker: The Dark Is Rising</field> <field name="director">Cunningham, David L.</field> <field name="genre">Adventure</field> <field name="genre">Drama</field> <field name="genre">Fantasy</field> <field name="genre">Thriller</field> <field name="actor">McShane, Ian</field> <field name="actor">Eccleston, Christopher</field> <field name="actor">Conroy, Frances</field> <field name="actor">Ludwig, Alexander</field> <field name="actor">Crewson, Wendy</field> <field name="actor">Warner, Amelia</field> <field name="actor">Cosmo, James</field> <field name="actor">Hickey, John Benjamin</field> <field name="actor">Piddock, Jim</field> <field name="actor">Lockhart, Emma</field> </add> <delete id="tt0301199" /> </batch>

documents/batch Request Elements (XML)

Element Description Required
batch The collection of add or delete operations that you want to submit to your search domain. A batch must contain at least one add or delete element. Yes
add Specifies a document that you want to add to your search domain. The id attributes is required and an add element must contain at least one field.

Attributes:

  • id—An alphanumeric string. Any characters other than A-Z (upper or lower case) and 0-9 are illegal. The max length is 128 characters.

No
field Specifies a field in the document being added. The name attribute and a field value are required. Field names must begin with a letter and can contain the following characters: a-z (lower case), 0-9, and _ (underscore). The name score is reserved and cannot be used as a field name. The field value can be text or CDATA.

To specify multiple values for a field, you include multiple field elements with the same name. For example:

<field name="genre">Adventure</field> <field name="genre">Drama</field> <field name="genre">Fantasy</field> <field name="genre">Thriller</field>

Constraints:

  • name—An alphanumeric string that begins with a letter. Can contain a-z (lower case), 0-9, _ (underscore), - (hyphen), and . (period).

Condition: At least one field must be specified in an add element.

Conditional
delete Specifies a document that you want to remove from your search domain. The id attribute is required. A delete element must be empty. For information on permanently deleting documents, see Deleting Documents in Amazon CloudSearch.

Constraints:

  • id—An alphanumeric string. Any characters other than A-Z (upper or lower case) and 0-9 are illegal.

No

documents/batch Response (XML)

The response body lists the number of adds and deletes that were performed and any errors or warnings that were generated.

The RelaxNG schema of a document service API response is:

start = response response = element response { attribute status { "success" | "error" }, attribute adds { xsd:integer }, attribute deletes { xsd:integer }, element errors { element error { text }+ }? & element warnings { element warning { text }+ }? }

documents/batch Response Elements (XML)

Element Description
result

Contains elements that list the errors and warnings generated when parsing and validating the request.

Attributes:

  • status—The result status, which is either success or error.

  • adds—The number of added documents. If the status is error, this is always zero.

  • deletes—The number of deleted documents. If the status is error, this is always zero.

Constraints: If the status is error, the results element contains a list of errors. If the status is success, the results element can contain a list of warnings, but no errors.

errors Contains a collection of error elements that identify the errors that occurred when parsing and validating the request.
error Provides information about a parsing or validation error. The value provides a description of the error.
warnings Contains a collection of warning elements that identify the warnings that were generated when parsing and validating the request.
warning Provides information about a parsing or validation warning. The value provides a description of the error.