title: AWS DynamoDB - combining multiple query filters on a single non-key attribute in java
body: <p>Earlier this year Amazon <a href="http://aws.amazon.com/blogs/aws/improved-queries-and-updates-for-dynamodb/" rel="noreferrer">announced</a> support of query filters on non-key attributes.</p>
  
  <p><strong>Can conditions be combined on a single attribute value? For example, in this scenario I would like to retrieve all items which do not match a certain list of values in a single 'non-key' column.</strong></p>
  
  <p>Their documentation states that each condition can only hold one attribute value for comparisons like <code>NOT_EQUALS</code> or <code>BEGINS_WITH</code>. The following therefore does not work:</p>
  
  <pre><code>HashMap&lt;String, Condition&gt; queryFilter = new HashMap&lt;String, Condition&gt;();
  
  List&lt;AttributeValue&gt; AttributeValues = new ArrayList&lt;AttributeValue&gt;();
  AttributeValues.add(new AttributeValue().withS("someValue1"));
  AttributeValues.add(new AttributeValue().withS("someValue2"));
  
  Condition attributeCondition = new Condition()
      .withComparisonOperator(ComparisonOperator.NE)
      .withAttributeValueList(AttributeValues);
  
  queryFilter.put("COLUMN_1", attributeCondition);
  
  DynamoDBQueryExpression&lt;Item&gt; queryExpression = new DynamoDBQueryExpression&lt;Item&gt;()
      .withHashKeyValues(itemKey)
      .withQueryFilter(queryFilter)
      .withLimit(pPageSize);
  </code></pre>
  
  <p>It looks like only the <code>IN</code> comparison operator can hold a list of attribute values. Ideally these conditions should be chainable? Since the query filter is a hash map we cannot put multiple conditions on the same column (I've tried):</p>
  
  <pre><code>Condition c1 = new Condition()
      .withAttributeValueList(new AttributeValue().withS("someValue1"))
      .withComparisonOperator(ComparisonOperator.NE);
  
  Condition c2 = new Condition()
      .withAttributeValueList(new AttributeValue().withS("someValue2"))
      .withComparisonOperator(ComparisonOperator.NE);
  
  DynamoDBQueryExpression&lt;Item&gt; queryExpression = new DynamoDBQueryExpression&lt;Item&gt;()
      .withHashKeyValues(itemKey)
      .withConditionalOperator(ConditionalOperator.AND)
      .withQueryFilterEntry("COLUMN_1", c1)
      .withQueryFilterEntry("COLUMN_1", c2)
      .withLimit(pPageSize);
  </code></pre>
  
  <p>Any help or clarification would be greatly appreciated!</p>
  
  <p>Thanks</p>