dynamodb: how to filer all items which do not have a certain attribute? -


i have table of users primary hash key of userid. each user may/may not have string attribute called "environment". users have "environment"="xyz" or not have "environment" attribute.

the following code filter users environment=xyz, how filter items no environment @ all? dynamo api not allow filter on empty string.

    amazondynamodbclient client = dbclientmanager.getdynamodbclient();      arraylist<attributevalue> avlist = new arraylist<attributevalue>();     avlist.add(new attributevalue().withs("xyz"));      condition scanfiltercondition = new condition()             .withcomparisonoperator(comparisonoperator.eq.tostring())             .withattributevaluelist(avlist);     map<string, condition> conditions = new hashmap<>();     conditions.put("environment", scanfiltercondition);      scanrequest scanrequest = new scanrequest()             .withtablename("users")             .withattributestoget(                     "userid",                      "environment");             .withscanfilter(conditions);      scanresult result = client.scan(scanrequest); 

for dropped scan filter, , filtering client-side. bit there way server side?

thanks, aliza

hope i'm not late. i've found useful function use in query. did not check scanrequest queryrequest works charm.

queryrequest queryrequest = new queryrequest()             .withtablename("youtablename")     queryrequest.setfilterexpression(" attribute_not_exists(yourattributename) ")     queryrequest.setexpressionattributevalues(expressionattributevalues)     queryrequest.setexclusivestartkey(ifyouhave)     queryrequest.setselect('all_attributes')     queryrequest.setexpressionattributenames(younames) 

attribute_not_exists(yourattributename) works ":aws-sdk:1.11.11" use attribute_exists(yourattributename)


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -