I have an idea to do LIKE search with small words in GAE.

The solution is create a Word model with the follow fields:

class Word(db.Model):
word = db.StringProperty()
like = db.StringListProperty()

# usage
word = Word()

word.word = "open"
# with the assignment above, the like property would automatically be
filled with the follow string list:
word.like = ["o", "op", "ope", "open", "p", "pe", "pen", "e", "en",
"n"]
word.put()

# a search would be like this:
part = "pen"
results = db.GqlQuery("SELECT * FROM Word WHERE like = :1", part)
# results would contain the word "open" cause it contains the
substring "pen" on the like list.

For optimization, repeated parts would not be saved on the list, for
example, the word "popo" would became:
word.like = ["p", "po", "pop", popo", "o", "op", "opo"]

The math to know how much words would exist on the list, is just do:
length * (1 + length) / 2
So a word with 20 letters would have a maximum of 210 subwords, minus
the repeated ones.
Thats why it just works for small words, in my case, for domain names,
or email address.

This idea came from 
http://code.google.com/events/io/sessions/BuildingScalableComplexApps.html
--~--~---------~--~----~------------~-------~--~----~
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