"like" operator in GQL

4,088 views
Skip to first unread message

Bruce Aloe

unread,
Sep 25, 2011, 2:55:46 PM9/25/11
to Google App Engine
Hello,

SQL supports "like" operator. I am wondering whether GQL supports the
"like" operator or not.

I have been looking at the GQL reference:
http://code.google.com/appengine/docs/python/datastore/gqlreference.html

However, the document doesnot mention anything it.

Is there any official document talking about this issue?

Any help is appreciated. Thanks.

Bruce

Barry Hunter

unread,
Sep 25, 2011, 3:03:11 PM9/25/11
to google-a...@googlegroups.com
No Like is not supported

Can use inquality filters to fake a StartsWith query (ie LIKE 'text%')
- in a case-sensitive fashion.
http://stackoverflow.com/questions/1402769/wildcard-search-on-appengine-in-python


You are probably looking for a 'full-text' style search? Its not
directly supported on AppEngine. Try searching the group for
full-text, there are loads of workarounds until Google implement a
full-text search system on appengine (its coming - we just dont know
when)

> --
> You received this message because you are subscribed to the Google Groups "Google App Engine" group.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
>
>

Brandon Wirtz

unread,
Sep 25, 2011, 3:45:33 PM9/25/11
to google-a...@googlegroups.com
If your content is something you want to search using like, consider storing
a Phonetic version of the data you want to search.

You might also consider Consonant only with "Consonant Pair Substitutions"

You would store
Dinosaur as DNSR
Google as GGL
GH replaces as F so rough is RF

This method isn't perfect but it works pretty well.

David

unread,
Sep 25, 2011, 4:07:59 PM9/25/11
to Google App Engine
It's not exactly like the LIKE statement, but this should work in a
similar fashion and return similar results for a LIKE 'abc%'

select * from MyEntity where myField >= 'abc' and myField < 'abd'

N. Rosencrantz

unread,
Sep 26, 2011, 2:18:45 AM9/26/11
to google-a...@googlegroups.com
Depending on your use case you might want to stick with google search i.e. adding the google search box via adsense while waiting for google to offer the full-text search functionality we require.
Regards,
Nick Rosencrantz

Prateek Malhotra

unread,
Sep 26, 2011, 4:55:27 PM9/26/11
to Google App Engine
Not available in GQL but I've had success utilizing IndexTank for full-
text search capabilities with AppEngine

bbaychev

unread,
Sep 27, 2011, 6:06:19 PM9/27/11
to Google App Engine
Have you tried SQLite syntax?

N. Rosencrantz

unread,
Sep 28, 2011, 9:18:43 AM9/28/11
to google-a...@googlegroups.com
These are among the drawbacks, minuses and reasons why app engine should be cheaper than traditional hosting:
- no join, no like, no full text search while sql-based system have these
- extremely difficult to migrate from M/S to HRD while sql-based system usually can migrate even large blobs
- sitemap.xml.gz has no good solution, you have to roll your own whereas legacy systems have ready solution to make a sitemap
- admin console with federated login breaks (other have phpmyadmin or tons of other solution while I don't have a backup system so my system is not real)
- "it's not good but it's the best we got"? regards \niklas

roberto.cr

unread,
Sep 28, 2011, 3:38:14 PM9/28/11
to Google App Engine
there are many differences between traditional relational databases
(like mysql) versus non-relational databases, aka nosql (like gae's
datastore)

but yes, "Full-text search over Datastore" is coming really soon

App Engine Product Roadmap
http://code.google.com/intl/en/appengine/docs/roadmap.html

Google I/O 2011: Full Text Search
Bo Majewski, Ged Ellis
http://www.youtube.com/watch?v=7B7FyU9wW8Y
(I recommend everyone here to take a look at it, it's really nice)

there were 2 main problems when I switched from my traditional mysql-
thinking to datastore-thinking: geo search and full text search.
the first is solved using GeoModel (made by some fine Google
employees), the second will come as a Google solution (see the video).

so I'm extremelly happy with GAE :) I hope you enjoy it too, Bruce.

N. Rosencrantz

unread,
Sep 28, 2011, 6:32:54 PM9/28/11
to google-a...@googlegroups.com
If I had to implement something like GQL "like" I think I would try to build many queries or a method like GQL IN without the limitations GQL IN has. I think non-rel db:s handles one problem much better: Everything from a HTTP request is a string like a parameter representing a boolean value must have some conversion somewhere and we don't want do to conversion since type conversion is expensive.

Since Google's environment for app engine is much more integrated than a traditional SQL system "stack" you patch together from different manufacturer, GQL much less has the problem of what or where a boolean variable is "True" True and not just 0 or 1 so I have places in my code how to represent a checkbox without doing any type conversion

if self.request.POST.get('group_article') == '1':
    article.group_article = True #checkbox variable

at some other place I also try to represent a boolean variable in a similar way but it's a onliner:

a.phoneview = self.request.get('phone_hidden', None) is not None
# dummy variable for whether phone number is visible

The later way I don't face the problem what is 1, '1', True etc it just abstracts away the difference so I should rewrite the first example to be more like the second
though I don't really understand the part "is not None"...

Cheers \niklas

Kunal Pariani

unread,
Jun 6, 2017, 2:22:25 PM6/6/17
to Google App Engine, wordsm...@gmail.com
This kind of query worked but i imagine this breaks the whole "Cloud Datastore reads scale because the only queries supported are those whose performance scales with the size of the result set (as opposed to the data set)"
concept. So doesn't that decrease the value of using Datastore at the first place for such thing ?

George (Cloud Platform Support)

unread,
Jun 7, 2017, 10:47:17 AM6/7/17
to Google App Engine
Indeed, the general imperative for scalability in App Engine is at odds with possible queries that would result in table scans. You may read more on the topic from the accepted reply to the "Google App Engine: Is it possible to do a Gql LIKE query?" question in Stackoverflow. 
Reply all
Reply to author
Forward
0 new messages