Kritias
Kritias

Reputation: 187

Objectify query filters like "name contains"

With Google App Engine using Objectify to query the datastore, I would like to use a query like

objectifyService.query(Entity.class).filter("name contains", a);

which would return a list with all the entities containing the 'a' caracter in their names. However the contains operator doesn't exist.

Is there a simple way to do that?

Upvotes: 1

Views: 1013

Answers (2)

stickfigure
stickfigure

Reputation: 13556

You can work up a simplified equivalent of the fulltext search service by breaking down your name field into the pieces you wish to search by and storing them as an indexed property. You can even use Lucene's analyzers to tokenize and stem your fields.

This comes up a lot when working with the datastore: If you don't have a query operator that does what you want, preindex relevant data so that your query is now an equality test.

Alternatively, use the FTS service.

Upvotes: 2

Amythus Crystala
Amythus Crystala

Reputation: 13

Answer is "operator doesn't exist" - Google datastore does not support this type of filter. To search, you should use Search engine : https://cloud.google.com/appengine/docs/java/search/

Upvotes: 0

Related Questions