1
我想要使用字符串集来过滤查询的结果。我的字符串集合由国家组成。Android DynamoDB使用字符串集过滤表达式
基本上,在执行查询之后,我希望过滤器查看字符串集的内容,然后仅显示谁是国家/地区的字符串集合的结果。这可能吗?这里是我有的代码:
String[] countries = { "Japan", "Vietnam", "Thailand"};
Map<String, AttributeValue> eav = new HashMap<String, AttributeValue>();
eav.put(":val2", new AttributeValue().withSS(countries));
DynamoDBQueryExpression queryExpression = new DynamoDBQueryExpression()
.withFilterExpression("Place IN (:val2)") // this is the line i'm confused about
.withExpressionAttributeValues(eav)
.withHashKeyValues(someHashValue);
// Results of query should only show those with Place = Japan, Vietnam, or Thailand
其中“地点”是我试图检查的列的名称。
我知道这样做的一种方法是使用多个OR语句来检查。但是,我希望此过滤器与任何字符串集大小兼容,因此看起来像OR语句不是要走的路。
我很欣赏任何指导。提前致谢!
Trey,非常感谢您的帮助!手动构建查询字符串对我的设计非常有用。我使用的唯一区别是我不想使用.join方法,因为它需要导入另一个库,所以我只是使用另一个for循环手动组合字符串和附加的OR。 谢谢Trey!真的很感激它! – skippyco