I think the answer is in the documentation for ListProperty:
http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html#ListProperty

In particular: "list_property < value tests if any of the members of
the list are less than the given value,..."

So your inequality filters will succeed for that entity because one
member of the list will be >= searchWord and another member of the
list will be < searchWord.

As to your question on doing both substring matching + ordering, I'll
think about it and post if I come up with something.
-Bill


On Jul 3, 12:43 pm, cerea <peonl...@gmail.com> wrote:
> Hi,
>
> I'm new to app engine & coding in general, so any help or advice would
> be greatly appreciated.
>
> Background:
> I am making a blog and each page has a list of keywords stored in a
> db.StringListProperty. Those keywords will be used when someone
> searches the site. I also want each keyword to have an integer
> associated with it which hold the number of occurrences of that
> keyword in the page.
>
> My Attempt:
> I have code which populates a StringListProperty named 'keywords' when
> a page is created. It looks like this: ["books_20", "lotto_100",
> "wallet_2"], where "books" is the keyword and "20" is the number of
> occurrences. My goal was to be able to perform a query to filter out
> all pages that starts with a certain keyword, then order it by the
> number of occurrences. Here is an example of my query:
>
> query = BlogPage.all()
> # my attempt at substring matching
> # based on the tip 
> here:http://code.google.com/appengine/docs/python/datastore/queriesandinde...
> query = query.filter('keywords >= ', searchWord)
> query = query.filter('keywords < ', searchWord + u"\ufffd")
> query.order('keywords')
>
> Problem:
> The query doesn't work correctly. If I search for the word "cat" even
> though it's not in the list, the blog page containing ["books_20",
> "lotto_100", "wallet_2"] still gets returned. I'm sure there is a
> logic behind the query and what is returned, but I don't understand.
>
> Questions:
> Is there a way to perform substring matching on a StringListProperty
> and also have it ordered? And Is there a better approach to what I'm
> trying to accomplish?
>
> Thanks so much for taking the time to read my post.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to