Amazon CloudSearch
Developer Guide (API Version 2011-02-01)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

documents/batch XML API

XML documents/batch Requests

The body of a documents/batch request uses the Search Data Format (SDF) to specify the document operations you want to perform. For example:

<batch>
	<add  id="tt0484562" version="1" lang="en">
		<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" version="1" />
</batch>

The Relax NG schema for an XML representation of a batch is shown below:

start = batch

sdf.field_name = xsd:token {
    minLength = "1"
    maxLength = "64"
    pattern = "[a-z0-9][a-z0-9_]{0,63}"
}

sdf.id = xsd:token {
    minLength = "1"
    maxLength = "128"
    pattern = "[a-z0-9][a-z0-9_]{0,127}"
}

sdf.version = xsd:integer {
    minExclusive = "0"
    maxExclusive = "4294967295"
}

batch = element batch {
    (element add {
        attribute id { sdf.id },
        attribute version { sdf.version },
        attribute lang { xsd:language },
        element field {
            attribute name { sdf.field_name },
            text
        }+
    }
    | element delete {
        attribute id { sdf.id },
        attribute version { sdf.version },
        empty
    })+
}

 

documents/batch Request Elements (XML)

ElementDescriptionRequired
batchThe 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
addSpecifies a document that you want to add to your search domain. The id, version, and lang attributes are 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.

  • version—Any non-negative number less than 2^32.

  • lang—An ISO-639-1 two-letter language code. English (en) is currently the only supported language.

No
fieldSpecifies 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 names "body", "docid", and "text_relevance" are reserved names and cannot be used as field names. 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
deleteSpecifies a document that you want to remove from your search domain. The id and version attributes are required. A delete element must be empty.

Constraints:

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

  • version—Any number less than 2^32. The version number specified must be higher than the document's current version number for the document to be deleted.

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)

ElementDescription
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.

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