Google App Engine: Is it possible to do a Gql LIKE query?
i'm facing the same problem, but i found something on google app engine pages:
Tip: Query filters do not have an explicit way to match just part of a string value, but you can fake a prefix match using inequality filters:
db.GqlQuery("SELECT * FROM MyModel WHERE prop >= :1 AND prop < :2",
"abc",
u"abc" + u"\ufffd")
This matches every MyModel entity with a string property prop that begins with the characters abc. The unicode string u"\ufffd" represents the largest possible Unicode character. When the property values are sorted in an index, the values that fall in this range are all of the values that begin with the given prefix.
http://code.google.com/appengine/docs/python/datastore/queriesandindexes.html
maybe this could do the trick ;)
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.