[google-appengine] Re: Query on partial string

2009-01-06 Thread chromerunner

Thanks Marzia, for two reasons (a) it is a valid workaround that I can
use and (b) I feel less incompetent in not having discovered an
obvious feature
--~--~-~--~~~---~--~~
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-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: Query on partial string

2009-01-06 Thread Marzia Niccolai
Hi,

With App Engine, there is not a great way to do partial string searches.  To
do prefix matching, which seems to be your use case, you can use inequality
filters and the method described here:
http://code.google.com/appengine/docs/datastore/queriesandindexes.html

"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."

-Marzia

On Tue, Jan 6, 2009 at 12:59 AM, chromerunner  wrote:

>
> A noob question. I have a series of names in the datastore. They are
> stored in this format: -. Examples would be:
>
> Smith-J
> Python-M
> Smith-KS
> Doe-J
>
> Users will want to find names by partial matching. Thus a query string
> of 'Smith' should find both J and KS above... I just can't find a way
> of doing it, am I missing what's glaringly obvious? Any pointers
> please? Thanks
>
> >
>

--~--~-~--~~~---~--~~
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-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---