du229908 2017-03-10 17:18
浏览 204
已采纳

无效的FilterExpression:语法错误DynamoDB

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
  • 写回答

1条回答 默认 最新

  • donglinxia1541 2017-03-10 20:58
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥15 键盘指令混乱情况下的启动盘系统重装