It doesn't look like there is a "NOT EQUALS" comparison operator in the QuerySpec withKeyConditionExpression or withFilterExpression. I'm trying to do something like:
new QuerySpec()
.withKeyConditionExpression("#name <> :var_name AND #date > :var_date")
.withNameMap(new NameMap()
.with("#name", "name")
.with("#date", "date"))
.withValueMap(new ValueMap()
.withString(":var_name","Unknown")
.withString(":var_date", thirtyDaysAgo));
Where name is not equal to the String "Unknown".
But, I get "Invalid operator used in KeyConditionExpress: <>.
Is there a way around this (other than excluding the condition from the query and iterating across the results in memory)?
I found the following documentation which references a not equal operator but it looks like it's not available in query filter.
Making Comparisons
Use these comparators to compare an operand against a range of values, or an enumerated list of values:
a = b — true if a is equal to b
a <> b — true if a is not equal to b
a < b — true if a is less than b
a <= b — true if a is less than or equal to b
a > b — true if a is greater than b
a >= b — true if a is greater than or equal to b
http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Condition.html
For a Query operation, Condition is used for specifying the KeyConditions to use when querying a table or an index. For KeyConditions, only the following comparison operators are supported:
EQ | LE | LT | GE | GT | BEGINS_WITH | BETWEEN
Condition is also used in a QueryFilter, which evaluates the query results and returns only the desired values.
NE : Not equal. NE is supported for all data types, including lists and maps.
AttributeValueList can contain only one AttributeValue of type String, Number, Binary, String Set, Number Set, or Binary Set. If an item contains an AttributeValue of a different type than the one provided in the request, the value does not match. For example, {"S":"6"} does not equal {"N":"6"}. Also, {"N":"6"} does not equal {"NS":["6", "2", "1"]}.