ScanFilter (legacy) - Amazon DynamoDB (original) (raw)

Note

We recommend that you use the new expression parameters instead of these legacy parameters whenever possible. For more information, see Using expressions in DynamoDB. For specific information on the new parameter replacing this one, use FilterExpression instead..

In a Scan operation, the legacy conditional parameter ScanFilter is a condition that evaluates the scan results and returns only the desired values.

Note

This parameter does not support attributes of type List or Map.

If you specify more than one condition in the ScanFilter map, then by default all of the conditions must evaluate to true. In other words, the conditions are ANDed together. (You can use theConditionalOperator (legacy) parameter to OR the conditions instead. If you do this, then at least one of the conditions must evaluate to true, rather than all of them.)

Each ScanFilter element consists of an attribute name to compare, along with the following:

Use FilterExpression instead – Example

Suppose you wanted to scan the Music table and apply a condition to the matching items. You could use aScan request with a ScanFilter parameter, as in this AWS CLI example:

aws dynamodb scan \
    --table-name Music \
    --scan-filter '{
        "Genre":{
            "AttributeValueList":[ {"S":"Rock"} ],
            "ComparisonOperator": "EQ"
        }
    }'

You can use a FilterExpression instead:

aws dynamodb scan \
    --table-name Music \
    --filter-expression 'Genre = :g' \
    --expression-attribute-values '{
        ":g": {"S":"Rock"} 
    }'