Google App Engine:是否可以执行GQL LIKE查询? [英] Google App Engine: Is it possible to do a Gql LIKE query?

查看:125
本文介绍了Google App Engine:是否可以执行GQL LIKE查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

真的很简单。在SQL中,如果我想为文本字段搜索几个字符,我可以这样做:

  SELECT blah FROM blah WHERE blah LIKE'%text%'

App Engine的文档没有提及如何实现这一点,但肯定它是一个常见的问题?

解决方案

BigTable是App Engine的数据库后端,可扩展到数百万记录。因此,App Engine不会允许您执行任何会导致表扫描的查询,因为对于填充良好的表而言,性能会很糟糕。



其他单词,每个查询都必须使用索引。这就是为什么你只能做 = > < 查询。 (事实上​​,你也可以做!= ,但API使用> 和<$ c )这也是为什么开发环境监视你所做的所有查询并自动将缺少的索引添加到 index.yaml file。



没有办法为 LIKE 查询建立索引,所以它根本不可用。 p>

观看此Google IO会话,以获得更好更详细的解释。


Simple one really. In SQL, if I want to search a text field for a couple of characters, I can do:

SELECT blah FROM blah WHERE blah LIKE '%text%'

The documentation for App Engine makes no mention of how to achieve this, but surely it's a common enough problem?

解决方案

BigTable, which is the database back end for App Engine, will scale to millions of records. Due to this, App Engine will not allow you to do any query that will result in a table scan, as performance would be dreadful for a well populated table.

In other words, every query must use an index. This is why you can only do =, > and < queries. (In fact you can also do != but the API does this using a a combination of > and < queries.) This is also why the development environment monitors all the queries you do and automatically adds any missing indexes to your index.yaml file.

There is no way to index for a LIKE query so it's simply not available.

Have a watch of this Google IO session for a much better and more detailed explanation of this.

这篇关于Google App Engine:是否可以执行GQL LIKE查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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