Reputation: 1659
I need to create an advanced Query Filter
that is capable to search letters inside a word.
For example, if I find the word gel
for Angel
it would be do a matched filter.
Filter propertyFilter = new FilterPredicate("name", FilterOperator.EQUAL, name);
Query<User> result = ObjectifyService.ofy().load().type(User.class)
.filter(propertyFilter);
The Query
works only if the word is equals to the match.
Upvotes: 1
Views: 226
Reputation: 13556
The datastore is a poor fit for this kind of thing. It is pretty straightforward to do prefix-matching or suffix-matching but arbitrary text in the middle of a string requires indexing each fragment that could match; eg Angel becomes [Angel, ngel, gel, el, l]
. It is somewhat expensive to store all this data and it doesn't scale well to long strings.
GAE's Search API tends to be better for this kind of thing, and stores the index more efficiently.
BTW this is a hard problem for databases. RDBMSes turn LIKE '%gel%'
into a table scan, which only works for small datasets. Fulltext search engines typically only search for words, not for interior substrings.
Upvotes: 3