Query

Description

The Query operation returns a set of ItemNames that match the query expression. Query operations that run longer than 5 seconds will likely time-out and return a time-out error response.

A Query with no QueryExpression matches all items in the domain.

[Note]Note

The current timeout for long queries is 5 seconds.

Your application should not excessively retry queries that return RequestTimeout errors. If you receive too many RequestTimeout errors, reduce the complexity of your query expression.

For information about limits that affect Query, see Amazon SimpleDB Limits.

Request Parameters

Name Description Required?
DomainName

The name of the domain to execute the query against.

Type: String

Yes
MaxNumberOfItems

Maximum number of ItemNames to return in the response.

Type: String

The range is 1 to 250.

The default setting is 100.

No
NextToken

String that tells Amazon SimpleDB where to start the next list of ItemNames.

Type: String

No
QueryExpression

The expression used to query the domain.

Type: String

Optional

Response Elements

Name Description
ItemName Item names that match the query expression.
NextToken An opaque token indicating that more than MaxNumberOfItems matched.

The Query operation returns a list of ItemNames that match the query expression. The maximum number that can be returned by one query is determined by MaxNumberOfItems which can be set to number between 1 and 250, inclusive. The default value for MaxNumberOfItems is 100. If more than MaxNumberOfItems items match the query expression, a NextToken is also returned. Submitting the query again with the NextToken will return the next set of items. To obtain all items matching the query expression, repeat until no NextToken is returned.

Special Errors

Error Description
InvalidParameterValue Value (" + value + ") for parameter MaxNumberOfItems is invalid. MaxNumberOfItems must be between 1 and 250.
InvalidNextToken The specified next token is not valid.
InvalidNumberPredicates Too many predicates in the query expression.
InvalidNumberValueTests Too many value tests per predicate in the query expression.
InvalidQueryExpression The specified query expression syntax is not valid.
MissingParameter The request must contain the parameter DomainName.
NoSuchDomain The specified domain does not exist.
RequestTimeout A timeout occurred when attempting to query domain <domain name> with query expression <query expression>. BoxUsage [<box usage value>]"

Examples

Sample Request

https://sdb.amazonaws.com/
?Action=Query
&AWSAccessKeyId=[valid access key id]
&DomainName=MyDomain
&MaxNumberOfItems=3
&NextToken=[valid next token]
&QueryExpression=%5B%27Color%27%3D%27Blue%27%5D
&SignatureVersion=1
&Timestamp=2007-06-25T15%3A03%3A09-07%3A00
&Version=2007-11-07
&Signature=2wVXB1x0NSWWETwLylZPVP%2FtqXQ%3D

Sample Response

<QueryResponse xmlns="http://sdb.amazonaws.com/doc/2007-11-07">
  <QueryResult>
    <ItemName>eID001</ItemName>
    <ItemName>eID002</ItemName>
    <ItemName>eID003</ItemName>
  </QueryResult>
  <ResponseMetadata>
    <RequestId>c74ef8c8-77ff-4d5e-b60b-097c77c1c266</RequestId>
    <BoxUsage>0.0000219907</BoxUsage>
  </ResponseMetadata>
</QueryResponse>