java - How to apply the search in list type field in dynamodb? -
we using $all in mongodb repository below:
@query(value = "{ 'subscriptions' : {$all : ?0 }}") public list<contentitem> findbysubscription(string[] subscriptioncode);
it works mongo need alternative in dynamodb
the below solution uses aws sdk dynamodb. currently, think there community version of spring data available dynamodb. so, have provided solution using aws sdk.
the contains
comparison operator can used search values in list data type.
contains supported lists: when evaluating "a contains b", "a" can list; however, "b" cannot set, map, or list.
example:-
queryspec queryspec = new queryspec(); queryspec.withkeyconditionexpression("yearkey = :yearval , title = :title") .withfilterexpression("contains (subscriptions, :subscriptions)") .withvaluemap( new valuemap().withnumber(":yearval", yearkey) .withstring(":title", title) .withstring(":subscriptions", subscriptions));
edit:-
currently, second parameter can't list because api can't process per specification. workaround use and condition multiple contains. example below:-
.withfilterexpression("contains (subscriptions, :subscriptions1) , contains (subscriptions, :subscriptions2)")
Comments
Post a Comment