This repository was archived by the owner on Jun 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 184
This repository was archived by the owner on Jun 28, 2023. It is now read-only.
Documentation uses contains condition in a KeyConditionExpression #187
Copy link
Copy link
Closed
Description
On this page https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SQLtoNoSQL.ReadData.Query.html there is an example that uses a contains condition in the KeyConditionExpression:
// Return all of the songs by an artist, with a particular word in the title...
// ...but only if the price is less than 1.00
{
TableName: "Music",
KeyConditionExpression: "Artist = :a and contains(SongTitle, :t)",
FilterExpression: "price < :p",
ExpressionAttributeValues: {
":a": "No One You Know",
":t": "Today",
":p": 1.00
}
}
While on this page https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html it is stated that you can use only use equality for the partition key and only greater than, greater than or equal, less than, less than or equal, equal, BETWEEN and begins_with for the sort key.
Key Condition Expression
To specify the search criteria, you use a key condition expression—a string that determines the items to be read from the table or index.
You must specify the partition key name and value as an equality condition.
You can optionally provide a second condition for the sort key (if present). The sort key condition must use one of the following comparison operators:
a = b — true if the attribute a is equal to the value b
a < b — true if a is less than b
a <= b — true if a is less than or equal to b
a > b — true if a is greater than b
a >= b — true if a is greater than or equal to b
a BETWEEN b AND c — true if a is greater than or equal to b, and less than or equal to c.
The following function is also supported:
begins_with (a, substr)— true if the value of attribute a begins with a particular substring.
The following AWS CLI examples demonstrate the use of key condition expressions. Note that these expressions use placeholders (such as :name and :sub) instead of actual values. For more information, see Expression Attribute Names and Expression Attribute Values.
One of these must be wrong and I suspect the example in https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SQLtoNoSQL.ReadData.Query.html is wrong.
Metadata
Metadata
Assignees
Labels
No labels