Dynamodb scan items by presence of a Document Type Map.AttributeName

Tags: ,



I have this Item structure:

{
    "Items": [
        {
            "serviceName": {
                "S": "B"
            },
            "sharedData": {
                "M": {
                    "five": {
                        "S": "5"
                    }
                }
            }
        }
}

I want to scan data by the presence of key five “five” within sharedData map. Something like sharedData.five exists or sharedData.five == *.

Is this possible?

Answer

aws dynamodb scan --table-name YOURTABLE --filter-expression 'attribute_exists(sharedData.five)'

Here is the CLI answer. You will need to turn it into Java, which is simple enough.



Source: stackoverflow