如何查询DynamoDb中的对象列表(使用CLI)

时间:2018-05-17 13:46:19

标签: amazon-dynamodb aws-cli dynamo-local dynamodb-queries

当我使用

扫描表时,下面是DynamoDb中表结构的样子
aws dynamodb scan --table-name "hotel" --endpoint-url  http://localhost:8088

{
    "Count": 2,
    "Items": [
        {
            "dc": {
                "N": "0"
            },
            "sw": {
                "L": [
                    {
                        "N": "1"
                    }
                ]
            }
        },
        {
            "dc": {
                "N": "0"
            },
            "sw": {
                "L":[]
            },
        }
    ],
    "ScannedCount": 2,
    "ConsumedCapacity": null
}

现在我想查询sw: []所在的表格。我正在使用以下查询来检索结果。

aws dynamodb query --table-name "hotel" --key-conditions  file:////tables/key1.json --endpoint-url http://localhost:8088 where 

key1.json

{
  "sw":{
    "ComparisonOperator":"EQ",
    "AttributeValueList": [ {"L":[]} ]
  }
}

但我得到以下错误

An error occurred (ValidationException) when calling the Query operation: Query condition missed key schema element

请建议我如何查询表格以检索结果。

1 个答案:

答案 0 :(得分:0)

表的结构化方式很难按其字段查询数组。尝试将每个项目保存为一行。