1

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

David Underhill
  • 15,206
  • 7
  • 50
  • 61
jb.
  • 777
  • 1
  • 7
  • 14

2 Answers2

2

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
  • 15,199
  • 3
  • 30
  • 37
  • 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. Mar 01 '10 at 14:47
1

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
  • 397
  • 2
  • 10
  • you can find Relation Index Entity examples for both Java and Python in my blogs: http://novyden.blogspot.com/2011/02/efficient-keyword-search-with-relation.html http://novyden.blogspot.com/2011/09/efficient-keyword-search-with-relation.html – topchef Sep 23 '11 at 19:53