Google App Engine and SQL LIKE

时光怂恿深爱的人放手 提交于 2019-12-08 08:09:42

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/2340649/google-app-engine-and-sql-like

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!