Luan Nico
Luan Nico

Reputation: 5917

FilterOperator NOT IN

com.google.appengine.api.datastore.Query.FilterOperator enum does not have a NOT_IN value. All other operations are possible (equal, not equal and all inequalities). Is it possible to create FilterPredicate with that behaviour (e.g., "id", notIn(), new int[] { 3, 4, 7 }, where notIn() is something that will make the query return all values except for those whose id's were found in the list given)? If not, them how can I query the datastore like that? Something like negating the FilterPredicate, for example.

Upvotes: 1

Views: 168

Answers (1)

Dave W. Smith
Dave W. Smith

Reputation: 24956

There isn't (as far as I know) server-side support for that type of query. Your best bet for simulating it client-side is to merge the result of three queries: one for elements below the min of the set, one for elements above the max of the set, and one for for [min..max] where you perform the not in in code on the client side.

(Added) You can perform all three queries in parallel to save wall time. A challenge will emerge if any of the queries returns a sufficiently large number of entities to either blow memory or exceed time limits.

Upvotes: 1

Related Questions