无效的FilterExpression:语法错误DynamoDB

时间:2017-03-10 17:18:14

标签: php amazon-web-services expression amazon-dynamodb

我正在尝试为我的查询添加一个新级别,并使用我的查询中的一个字段来进一步搜索,但我无法理解我的查询有什么问题。这是现在看来的数据

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
)

我的语法有什么问题吗?如果我不使用FilterExpression,则查询运行正常。这是我收到的错误消息

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

1 个答案:

答案 0 :(得分:1)

您的 FilterExpression 语法无效。您需要将表达式编写为'FilterExpression' => 'dob > :value'(将GT替换为>)。

Syntax for Condition Expressions。请注意, FilterExpression 的语法与 ConditionExpression 的语法相同。