我在表中的每个项目中都设置了一个字符串。例如,
{
Title = "Book 101 Title"
ISBN = "111-1111111111"
Authors = "Author 1"
Price = -2
Dimensions = "8.5 x 11.0 x 0.5"
PageCount = 500
Color = [ "Red", "Black" ]
ProductCategory = "Book"
}
{
Title = "Book 102 Title"
ISBN = "222-222222222"
Authors = "Author 2"
Price = -8
Dimensions = "8.5 x 11.0 x 0.5"
PageCount = 700
Color = [ "Red", "Green" ]
ProductCategory = "Book"
}
使用 dynamoDB php sdk,我想获取“红色”颜色的项目。我尝试这样。
$response = $client->query(array(
"TableName" => $tablename,
"KeyConditions" => array(
"ComparisonOperator" => ComparisonOperator::CONTAINS,
'Color' => array(
'AttributeValueList' => array(
array(Type::STRING_SET => array("Red"))
),
)
));
但我遇到了这样的错误。
ValidationException: One or more parameter values were invalid: ComparisonOperator CONTAINS is not valid for SS AttributeValue type
我从aws开发者论坛找到了解决方案here https://forums.aws.amazon.com/thread.jspa?messageID=351861#jive-message-351861。无法使用CONTAINS
with query
。必须与它一起使用scan
。像那样。
$response = $client->scan(array(
"TableName" => $tablename,
"KeyConditions" => array(
"ComparisonOperator" => ComparisonOperator::CONTAINS,
'Color' => array(
'AttributeValueList' => array(
array(Type::STRING => "Red")
),
)
));
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)