Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Datastore GQL LIKE condition
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Expand all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
hads  
View profile  
 More options Apr 13 2008, 3:57 am
From: hads <hadley.r...@gmail.com>
Date: Sun, 13 Apr 2008 00:57:16 -0700 (PDT)
Local: Sun, Apr 13 2008 3:57 am
Subject: Datastore GQL LIKE condition
Hi all,

I'm aware that the datastore isn't a relational database and as such
doesn't support many relational database features.

I'm wanting to create a street address lookup with a model something
like this;

class Address(db.Model):
        street = db.StringProperty()
        suburb = db.StringProperty()
        postcode = db.StringProperty()
        city = db.StringProperty()
        lon = db.StringProperty()
        lat = db.StringProperty()

The thing I'm trying to get my head around is how to query for results
with a partial address i.e. "For" returning ("Forest Street", "Forman
Avenue", ...).

Normally one could do this with a LIKE condition (SELECT * FROM
address WHERE street LIKE 'For%'). I'm not sure how I would go about
this using the datastore since it only supports the common comparison
operators.

Does anyone have any insights on how to achieve this end result in
some way using the datastore?

Many thanks,

hads


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hubert Chen  
View profile  
 More options Apr 13 2008, 4:09 am
From: Hubert Chen <hub...@gmail.com>
Date: Sun, 13 Apr 2008 01:09:13 -0700 (PDT)
Local: Sun, Apr 13 2008 4:09 am
Subject: Re: Datastore GQL LIKE condition
You'd have to select all rows and then do a regex match in your code.

On Apr 13, 12:57 am, hads <hadley.r...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brett Morgan  
View profile  
 More options Apr 13 2008, 4:24 am
From: "Brett Morgan" <brett.mor...@gmail.com>
Date: Sun, 13 Apr 2008 18:24:41 +1000
Local: Sun, Apr 13 2008 4:24 am
Subject: Re: [google-appengine] Datastore GQL LIKE condition
I'd probably head down the path of maintaining a trie for all the
words in the fields you want partial search on. This would give you
the ability to do ajax drop down completion on the fields after two or
three characters.

http://en.wikipedia.org/wiki/Trie


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
hads  
View profile  
(1 user)  More options Apr 13 2008, 4:34 am
From: hads <hadley.r...@gmail.com>
Date: Sun, 13 Apr 2008 01:34:00 -0700 (PDT)
Subject: Re: Datastore GQL LIKE condition
On Apr 13, 8:24 pm, "Brett Morgan" <brett.mor...@gmail.com> wrote:

> I'd probably head down the path of maintaining a trie for all the
> words in the fields you want partial search on. This would give you
> the ability to do ajax drop down completion on the fields after two or
> three characters.

> http://en.wikipedia.org/wiki/Trie

Thanks Brett, that's one idea I had thought of and I guess the only
real solution.

Hubert, unfortunately that wouldn't work in this situation. For one
the data set is far too large (every street name in the country) to
process like that and secondly it would be over the limits of the
datastore api.

Cheers,

hads


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brett Morgan  
View profile  
 More options Apr 13 2008, 4:50 am
From: "Brett Morgan" <brett.mor...@gmail.com>
Date: Sun, 13 Apr 2008 18:50:23 +1000
Local: Sun, Apr 13 2008 4:50 am
Subject: Re: [google-appengine] Re: Datastore GQL LIKE condition
What i'd think would be a first approximation, given your dataset
size, would be to start the trie at something like three characters,
and have a seperate datastore entity for each of those start nodes.

I suspect you are going to have to precompute the trie on your desktop
and bulk upload it tho.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
hads  
View profile  
 More options Apr 13 2008, 5:01 am
From: hads <hadley.r...@gmail.com>
Date: Sun, 13 Apr 2008 02:01:30 -0700 (PDT)
Local: Sun, Apr 13 2008 5:01 am
Subject: Re: Datastore GQL LIKE condition
On Apr 13, 8:50 pm, "Brett Morgan" <brett.mor...@gmail.com> wrote:

> What i'd think would be a first approximation, given your dataset
> size, would be to start the trie at something like three characters,
> and have a seperate datastore entity for each of those start nodes.

That's my thought too.

> I suspect you are going to have to precompute the trie on your desktop
> and bulk upload it tho.

Yeah. I'm currently playing with the comparison operators after
finding a tip on the following page (I thought I'd read all the docs -
must have missed that bit);

http://code.google.com/appengine/docs/datastore/queriesandindexes.html

This may be an easier route.

Cheers,

hads


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brett Morgan  
View profile  
 More options Apr 13 2008, 5:03 am
From: "Brett Morgan" <brett.mor...@gmail.com>
Date: Sun, 13 Apr 2008 19:03:49 +1000
Local: Sun, Apr 13 2008 5:03 am
Subject: Re: [google-appengine] Re: Datastore GQL LIKE condition

I don't see how comparison operators help with partial word matching.
Please tell us how it works out. =)

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
hads  
View profile  
(3 users)  More options Apr 13 2008, 5:15 am
From: hads <hadley.r...@gmail.com>
Date: Sun, 13 Apr 2008 02:15:06 -0700 (PDT)
Local: Sun, Apr 13 2008 5:15 am
Subject: Re: Datastore GQL LIKE condition
On Apr 13, 9:03 pm, "Brett Morgan" <brett.mor...@gmail.com> wrote:

> I don't see how comparison operators help with partial word matching.
> Please tell us how it works out. =)

Confused me for a minute too :)

The tip on that page is at the bottom of the "Introducing Indexes"
section.

I'm currently using something like this;

q = 'For'
addresses = db.GqlQuery('SELECT * FROM Address WHERE street >= :1 AND
street < :2', q, q + 'z')

which works fine. Now all I need to do is store a lowercase name with
every entity.

Thanks for the discussion.

hads


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brett Morgan  
View profile  
 More options Apr 13 2008, 5:19 am
From: "Brett Morgan" <brett.mor...@gmail.com>
Date: Sun, 13 Apr 2008 19:19:15 +1000
Local: Sun, Apr 13 2008 5:19 am
Subject: Re: [google-appengine] Re: Datastore GQL LIKE condition

*lightbulb*

>  Thanks for the discussion.

Thank you, takes two to tango and all that. *grin*

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google