Objectify查询过滤器,如“name contains” [英] Objectify query filters like "name contains"

查看:149
本文介绍了Objectify查询过滤器,如“name contains”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Google App Engine使用Objectify查询数据存储,我想使用一个查询,如

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);

这将返回一个包含名称中包含'a'caracter的所有实体的列表。然而,包含运算符不存在。

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?

推荐答案

您可以通过将您的姓名字段分解为您希望搜索的部分并将其存储为索引属性,来处理简化的全文搜索服务。您甚至可以使用Lucene的分析器来标记和阻止您的字段。

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.

使用数据存储时会出现很多问题:如果您没有查询运算符,你想要什么,preindex相关数据,以便你的查询现在是一个平等测试。

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.

或者,使用FTS服务。

Alternatively, use the FTS service.

这篇关于Objectify查询过滤器,如“name contains”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆