Reputation: 283
I am trying to add a new level to my queries and use one of the fields in my query to further the search but I have not been able to understand what is wrong with my query. Here is the data as it looks right now
Array
(
[TableName] => usuarios
[IndexName] => nombre-apellido-index
[KeyConditions] => Array
(
[nombre] => Array
(
[ComparisonOperator] => EQ
[AttributeValueList] => Array
(
[0] => Array
(
[S] => Carlos
)
)
)
[apellido] => Array
(
[ComparisonOperator] => BEGINS_WITH
[AttributeValueList] => Array
(
[0] => Array
(
[S] => Rodriguez
)
)
)
)
[ScanIndexForward] =>
[Select] => ALL_ATTRIBUTES
[ReturnConsumedCapacity] => TOTAL
[ConsistentRead] =>
[FilterExpression] => dob GT :value
[ExpressionAttributeValues] => Array
(
[:value] => Array
(
[S] => 1988-03-07
)
)
[Limit] => 100
)
Is there anything wrong with my syntax? If I don't use FilterExpression
the query runs fine. Here is the error message I get
Fatal error: Uncaught exception 'Aws\DynamoDb\Exception\DynamoDbException' with message 'Error executing "Query" on "https://dynamodb.us-east-1.amazonaws.com"; AWS HTTP error: Client error: 400 ValidationException (client): Invalid FilterExpression: Syntax error; token: "GT", near: "dob GT :value" - {"__type":"com.amazon.coral.validate#ValidationException","message":"Invalid FilterExpression: Syntax error; token: \"GT\", near: \"dob GT :value\""}' exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: 400' in _aws/3.3.0/GuzzleHttp/Middleware.php:69 Stack trace: #0 _aws/3.3.0/GuzzleHttp/Promise/Promise.php(199): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response)) #1 _aws/3.3.0/GuzzleHttp/Promise/Promise.php(152): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #2 _aws/3.3.0/GuzzleHttp/Promise/TaskQueue.php(60): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() #3 /v in _aws/3.3.0/Aws/WrappedHttpHandler.php on line 152
Upvotes: 2
Views: 16303
Reputation: 10547
Your FilterExpression has invalid syntax. You'll need to write your expression as 'FilterExpression' => 'dob > :value'
(replace GT
with >
).
See Syntax for Condition Expressions. Note that the syntax for FilterExpression is identical to that of ConditionExpression.
Upvotes: 2