GQL "IS NOT NULL" and "LIKE" queries

743 views
Skip to first unread message

ssprauer

unread,
Aug 6, 2009, 6:48:24 AM8/6/09
to Google App Engine
I am looking forward to code some GQL queries that would retrieve data
like SQL "IS NOT NULL" and "LIKE" queries.

I would be very grateful to see an example...

Cheers,

Steve

ssprauer

unread,
Aug 6, 2009, 3:12:56 AM8/6/09
to Google App Engine
I looked in the GQL reference but it looks like it s not possible to
execute "IS NOT NULL" and "LIKE" queries...
If anybody had a how-to or a workaround, that would be most
welcomed :)

Tanks,

Steve

Barry Hunter

unread,
Aug 6, 2009, 3:21:40 PM8/6/09
to google-a...@googlegroups.com
You cant do full 'like' capabilities, but can do basic 'startswith'
using the trick mentiond here:
http://code.google.com/appengine/docs/python/datastore/queriesandindexes.html#Introducing_Indexes

Also have a look around for the various 'full text' search implementations.

For 'NOT' you do have != which will probably work with 'None' which is
close to a python equivalent of null. This will have to variable
subsituation rather than a string constant to put the 'none' there
though.


2009/8/6 ssprauer <stephane...@gmail.com>:
--
Barry

- www.nearby.org.uk - www.geograph.org.uk -

Hrishikesh Bakshi

unread,
Aug 6, 2009, 4:08:53 PM8/6/09
to google-a...@googlegroups.com

Basic MySQL Like functionality using Java

Step 1: Fetch the whole table

Step 2: For each row:
query= query.toLowerCase();
temp = dbname.getTablename().toLowercase

if(temp.contains(query)){
//do stuff...
}


Hope it helps..
--
Hrishikesh Bakshi

ssprauer

unread,
Aug 7, 2009, 7:23:44 AM8/7/09
to Google App Engine
thank you so much for this guys!
you rock...cant wait to try this tomorrow hehehe

On Aug 6, 10:08 pm, Hrishikesh Bakshi <bakshi.hrishik...@gmail.com>
wrote:
> Basic MySQL Like functionality using Java
>
> Step 1: Fetch the whole table
>
> Step 2: For each row:
> query= query.toLowerCase();
> temp = dbname.getTablename().toLowercase
>
> if(temp.contains(query)){
> //do stuff...
>
> }
>
> Hope it helps..
>
> On Thu, Aug 6, 2009 at 3:21 PM, Barry Hunter <barrybhun...@googlemail.com>wrote:
>
>
>
>
>
>
>
> > You cant do full 'like' capabilities, but can do basic 'startswith'
> > using the trick mentiond here:
>
> >http://code.google.com/appengine/docs/python/datastore/queriesandinde...
>
> > Also have a look around for the various 'full text' search implementations.
>
> > For 'NOT' you do have != which will probably work with 'None' which is
> > close to a python equivalent of null. This will have to variable
> > subsituation rather than a string constant to put the 'none' there
> > though.
>
> > 2009/8/6 ssprauer <stephane.spra...@gmail.com>:

Wooble

unread,
Aug 7, 2009, 12:12:47 PM8/7/09
to Google App Engine


On Aug 6, 4:08 pm, Hrishikesh Bakshi <bakshi.hrishik...@gmail.com>
wrote:
> Basic MySQL Like functionality using Java
>
> Step 1: Fetch the whole table

Doesn't scale; once your "table" is big enough, you're going to start
exceeding the request deadline.

Hrishi

unread,
Aug 7, 2009, 12:56:51 PM8/7/09
to Google App Engine

If you are thinking of using the LIKE statement of MySQL, you should
not be having a huge table.

If you have entries in 10000s, it works great.

Wooble

unread,
Aug 7, 2009, 10:35:21 PM8/7/09
to Google App Engine


On Aug 7, 12:56 pm, Hrishi <bakshi.hrishik...@gmail.com> wrote:
> If you are thinking of using the LIKE statement of MySQL, you should
> not be having a huge table.
>
> If you have entries in 10000s, it works great.

I've never been able to fetch anywhere close to 10,000 entities in a
single request. YMMV.

Jaap Taal

unread,
Aug 10, 2009, 1:58:57 PM8/10/09
to google-a...@googlegroups.com
Guys,

If you want to have prefix searches, you might want to google for:
whoosh app engine. Whoosh is a lucene like indexer in pure python. Someone has created a app engine component.
Haven't done a lot with it, but it works quite OK.

Jaap
Reply all
Reply to author
Forward
0 new messages