views:

237

answers:

2

Is there any way to query GAE datastore with filter similar to SQL LIKE statement? For example, if a class has a string field, and I want to find all classes that have some specific keyword in that string, how can I do that? It looks like JDOQL's matches() don't work... Am I missing something?

Any comments, links or code fragments are welcome

+2  A: 

As the GAE/J docs say, BigTable doesn't have such native support. You can use JDOQL String.matches for "something%" (i.e startsWith). That's all there is. Evaluate it in-memory otherwise.

DataNucleus
Thanks for your reply. The bad thing about startsWith() is that it can't be used with inequality operators on other fields, so I'll have to evaluate in memory anyway.
jb
+1  A: 

If you have a lot of items to examine you want to avoid loading them at all. The best way would probably be to break down the inputs a write time. If you are only searching by whole words then that is easy

For example, "Hello world" becomes "Hello", "world" - just add both to a multi valued property. If you have a lot of text you want to avoid loading the multi valued property because you only need it for the index lookup. You can do this by creating a "Relation Index Entity" - see bret slatkins Google IO talk for details.

You may also want to break down the input into 3 character, 4 character etc strings or stem the words - perhaps with a lucene stemmer.

John Patterson