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/queriesandindexes.html#Introducing_Indexes
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to