Search code examples
javagoogle-app-enginegoogle-cloud-datastorejdoql

App Engine datastore does not support operator OR


I am trying to query the google datastore for something like (with pm --> persistanceManager):

String filters = "(  field == 'value' ||  field == 'anotherValue' )";
Query query = pm.newQuery(myType.class, filters);

When I execute - I am getting back: App Engine datastore does not support operator OR.

What's the best approach in people experience for this kind of queries?

Any help appreciated!


Solution

  • Perform multiple queries. The Datastore, like all other databases, isn't able to efficiently execute disjunctions. Unlike other databases, it exposes this difficulty to the user, to make it clear that what you're doing isn't efficient. Your only solution is to execute multiple queries - one for each or - and combine them.