For what you want to do, you're probably best served using the search
API (added in 1.7).
There are docs available, but essentially you create a new "search" index and "documents" which you must add to the index by creating them from your existing data. The search index is a different, fully searchable type of index which but which is still stored in your datastore.
As a hackish alternative to this, if you store the free text you want to search against in a StringListProperty
(you will probably have to update your model and migrate your data to be split into individual words), then you can "search" against this with a simple equality operator (=
) which is roughly equivalent to an in
in python:
search_string = "Reading"
q = MentorServices.all()
q.filter("Services =", search_string)
q.fetch()
I strongly suggest using the search
API instead of this, because:
- You have to migrate all of your
TextProperty
fields that you want to search toStringListProperty
fields before this will work - Using
StringListProperty
fields is not efficient for storing text - The alternative
search
API was created precisely to avoid these kinds of solutions.
If you controlled how users entered the data, for example by having them enter a set of skills as tags, then they would be more easily saved as a StringListProperty
and it would make more sense to search in this manner. For searching unstructured text, use the search
API.