本文介绍了Dynamodb查询-KeyConditionExpression中的OR条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个DynamoDB表,其中 feed_guid 作为全局二级索引。我想在该表中使用一组 feed_guid 进行查询。由于 feed_guid 不是我的主键,因此我不能使用 getBatchItem 。当我尝试以下方法时,出现此错误:

I have a DynamoDB table with feed_guid as the global secondary index. I want to query with a set of feed_guid in that table. Since feed_guid is not my primary keys, I can't use getBatchItem. When I tried the following method, I got this error:



    $options = array(
                'TableName' => 'feed',
                    'IndexName' => 'GuidIndex',
                    'KeyConditionExpression' => 'feed_guid = :v_guid1 or feed_guid = :v_guid2',

                    'ExpressionAttributeValues' =>  array (
                        ':v_guid1' => array('S' => '8a8106e48bdbe81bf88d611f4b2104b5'),
                        ':v_guid2' => array('S' => '19cab76242a6d85717de64fe4f8acbd4')
                    ),
                    'Select' => 'ALL_ATTRIBUTES',
                );
                $response = $dynamodbClient->query($options);


推荐答案

您不能使用条件。您应该使用

You can't use OR condition. You should use

rangeAttributeName BETWEEN :rangeval1 AND :rangeval2

(如果可能)或

feed_guid IN (:v_guid1, :v_guid2)

请参见和

这篇关于Dynamodb查询-KeyConditionExpression中的OR条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 06:06