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.

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

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分