2017-10-03 4 views
0

J'ai document et ce document stocke le travail du système. Je veux obtenir la liste de travail excepté que je ne voulais pas obtenir un certain travail si le statut de travail contient des mots ANNULÉS et CRÉÉS.QueryFilter avec plusieurs contiennent DynamoDb

ItemCollection<QueryOutcome> items = index.query(new QuerySpec().withHashKey("deviceId", "string1") 
     .withQueryFilters(new QueryFilter("currentState").notContains("CANCELED").notContains("CREATED"))); 

Mais ce code renvoie également des jobs avec status = ANNULÉ. J'ai besoin d'aide. Pourriez-vous pls ?? :)

enter image description here

Répondre

0

Interrogation Spec avec ne contient pour l'attribut Chaîne: -

QuerySpec spec = new QuerySpec() .withKeyConditionExpression("deviceId = :v_id") .withFilterExpression("not(contains(currentState, :version) or contains(currentState, :currentState))") .withValueMap(new ValueMap() .withString(":v_id", "string1") .withString(":version", "CANCELED") .withString(":currentState", "CREATED")); ItemCollection<QueryOutcome> items1 =index.query(spec); 
+0

que vous avez mentionné je ne pourrais pas mettre en œuvre ma fonction comme ça, mais qui fonctionne pour moi spec QuerySpec = new QuerySpec() .withKeyConditionExpression ("deviceId =: v_id") .withFilterExpression ("not (contient (currentState,: version) ou contient (currentState,: currentState))") .withValueMap (new ValueMap() .withString (": v_id", "string1") .withString (": version", "CANCELED") .withString (": currentState", "CREATED")); ItemCollection items1 = index.query (spec); –

+0

D'accord avec vous. J'ai mis à jour la réponse pour d'autres avantages. – notionquest