Performing a "LIKE" query in GQL ??

62 views
Skip to first unread message

Chathum Henegama

unread,
Apr 19, 2011, 4:41:24 AM4/19/11
to Google App Engine
Hi i need to do a search for some data store in a table. If a user
searches for "foo" i should get all the values containing "foo".. Can
anyone help me with this ?

nischalshetty

unread,
Apr 19, 2011, 6:23:23 AM4/19/11
to google-a...@googlegroups.com
Have a look at "ListProperty" if u're on the Python stack or in java you can do this :

class {

private List<String> props;

}


query.setFilter(" props == 'foo'");

So, basically, create a list containing all the searchable tokens and then you can easily search in the way described above.

Kaan Soral

unread,
Apr 19, 2011, 4:49:14 PM4/19/11
to Google App Engine
I also need a similiar function, I was thinking of:
- putting everything to one document and manually searching for
something (memory limit? - for some reason no one gives an estimation
on a request's memory limit)
- searching every element one by one using background tasks
(expensive)
- combining idea 1 and 2

When I asked about this on IRC pfn recommended what nischalshetty
recommended
Pros:
- Very simple to implement
Cons:
- Deciding how deep the indexing will go (will you add each prefix?)
- Limited search

I am thinking of doing it like:
phrase: "the action game"
["the","action","game","the action","action game","the action game"]

it may also be every subsets which is 2^N, but I guess its a lot, so
continuous sequences sound better

I am definitely not diving into prefixes

Thinking about it now, continuous sequences up to length 2 is the way
to go for me
phrase: "very good game action"
["very","good","game","action","very good","good game","game action"]
and probably adding the whole thing too:
["very","good","game","action","very good","good game","game
action","very good game action"]

Ernesto Oltra

unread,
Apr 20, 2011, 4:57:15 AM4/20/11
to google-a...@googlegroups.com
Remember you can use inequality filters to match different suffixes at once:

["use", "useless", "useful"]

will be matched by this query:

db.GqlQuery('SELECT * FROM nowhere WHERE prop >= "use" and prop <= "use' + u'\uFFFF' + ' " ')

because useL > use and useL < use[the bigger char in unicode]

Max

unread,
Nov 11, 2011, 6:08:07 AM11/11/11
to google-a...@googlegroups.com
check out project Yaac! (http://code.google.com/p/yaac/)

it now supports LIKE query
Reply all
Reply to author
Forward
0 new messages