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

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

问题描述

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

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%'

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

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

推荐答案

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

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.

换句话说,每个查询都必须使用索引.这就是为什么您只能执行 =>< 查询的原因.(实际上,您也可以执行 !=,但 API 使用 >< 查询的组合来执行此操作.)这也是为什么开发环境会监控您执行的所有查询并自动将任何缺失的索引添加到您的 index.yaml 文件中.

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.

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

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

观看这个 Google IO session 以获得更好、更详细的解释.

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天全站免登陆