Reputation: 8420
I have this scan but I need to put an aditional filter:
aws dynamodb scan
--table-name my-table
--filter-expression "attribute_type(#code.#cor, :v_sub)"
--expression-attribute-names '{"#code": "sender", "#cor": "custom:myAttribute"}'
--expression-attribute-values '{":v_sub":{"S":"N"}}'
This works fine but now I want to scan only when the attribute createdAt
(it's a string date) CONTAINS the string 2020-10
I was trying something like:
aws dynamodb scan
--table-name my-table
--scan-filter '{"createdAt":{"AttributeValueList": [{"S":"2020-10"}], "ComparisonOperator": "CONTAINS"}}'
--filter-expression "attribute_type(#code.#cor, :v_sub)"
--expression-attribute-names '{"#code": "sender", "#cor": "custom:myAttribute", "#created": "createdAt"}'
--expression-attribute-values '{":v_sub":{"S":"N"}, ":date":{"S":"S"}}'
But I get a: Can not use both expression and non-expression parameters in the same request: Non-expression parameters: {ScanFilter} Expression parameters: {FilterExpression}
How can I filter for that comparison operator CONTAINS in my working scan?
Upvotes: 1
Views: 1623
Reputation: 8420
I had to use only filter-expression
each filter with and
and using the function contains()
:
aws dynamodb scan
--table-name my-table
--select "COUNT"
--filter-expression "attribute_type(#code.#cor, :v_sub) and contains(createdAt,:created)"
--expression-attribute-names '{"#code": "sender", "#cor": "custom:myAttribute"}'
--expression-attribute-values '{":v_sub":{"S":"N"}, ":created":{"S": "2020-10"}}
Upvotes: 3