Objectify query filters like “name contains”

本小妞迷上赌 提交于 2019-12-23 02:31:18

问题


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?


回答1:


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.




回答2:


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/



来源:https://stackoverflow.com/questions/27595327/objectify-query-filters-like-name-contains

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