简体   繁体   English

AWS Dynamo数据库搜索

[英]aws dynamo db search

I have the following keys.txt 我有以下keys.txt

{
    "test": {"BOOL": true}
}

I run the following command aws dynamodb get-item --table-name marvel-users-prod --key file://keys.json 我运行以下命令aws dynamodb get-item --table-name marvel-users-prod --key file://keys.json

but its not returning the items that match the key/value. 但它不返回与键/值匹配的项目。 What am I doing wrong? 我究竟做错了什么?

I get the error 我得到错误

A client error (ValidationException) occurred when calling the GetItem operation: The provided key element does not match the schema

I tried using the GUI but the scan stopped. 我尝试使用GUI,但扫描停止。

Get-item can be used to get the data by primary key. Get-item可用于通过主键获取数据。 The DynamoDB hash key can't be BOOL type. DynamoDB哈希键不能为BOOL类型。

The get-item operation returns a set of attributes for the item with the given primary key. get-item操作使用给定的主键返回该项目的一组属性。 If there is no matching item, get-item does not return any data. 如果没有匹配的项目,则get-item不返回任何数据。

Create Table Attribute Types:- 创建表属性类型:-

"AttributeType": "S"|"N"|"B" “ AttributeType”:“ S” |“ N” |“ B”

Also, I assume that the boolean attribute that you would like to filter is one of the attributes in the Dynamodb table. 此外,我假设您要过滤的布尔属性是Dynamodb表中的属性之一。 You may need to scan the table if you don't include the hash key in the filter criteria. 如果您在筛选条件中未包含哈希键,则可能需要扫描表。

Scan command:- 扫描命令:

"interested" - is my BOOL attribute name “感兴趣”-是我的BOOL属性名称

:a - Attribute value placeholder. :a-属性值占位符。 The value is present in the JSON file 该值存在于JSON文件中

aws dynamodb scan --table-name autotable --filter-expression "interested = :a" --expression-attribute-values file://scan-movies.json

Scan Movies JSON file:- 扫描电影JSON文件:-

{
  ":a": {"BOOL" : true}
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM