[英]Google app engine or query (python)
Can anyone share your approach for doing a 'or' query in app-engine? 任何人都可以分享您在app-engine中执行'或'查询的方法吗?
Let say I have 我想说
class A_db_model(db.Model):
valueA = db.ListProperty(basestring)
in valueA I have 在价值我有
aaa
aaa, bbb
bbb
ccc
I would like to return result of if the valueA match 'aaa' or 'bbb' and return not duplicated result. 如果值A匹配'aaa'或'bbb'并返回不重复的结果,我想返回结果。
Try this? 试试这个?
A_db_model.all().filter('valueA IN', ['aaa', 'bbb'])
or the equivalent GQL: 或等效的GQL:
GqlQuery('SELECT * FROM A_db_model WHERE valueA IN :1', ['aaa', 'bbb'])
The two main problems with @Amber's approach is that it is slow as it basically runs a query for each value behind the scenes and it maxes out at 30 values to query for. @ Amber方法的两个主要问题是它很慢,因为它基本上对幕后的每个值运行一个查询,并且最多可以查询30个值。 I just wrote a blog post about this question.
我刚写了一篇关于这个问题的博文。 It explains the best scalable way to basically do an OR query with app engine.
它解释了基本上使用app引擎进行OR查询的最佳可扩展方式。 You can use a separate entity to make this happen.
您可以使用单独的实体来实现此目的。 See the post for details.
有关详细信息,请参阅帖子
http://tornblue.com/post/11310830291/app-engine-how-to-do-an-efficient-or-query http://tornblue.com/post/11310830291/app-engine-how-to-do-an-efficient-or-query
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.