'Search the index for documents matching the query.
For example, the following code fragment requests a search for
documents where \'first\' occurs in subject and \'good\' occurs anywhere,
returning at most 20 documents, starting the search from \'cursor token\',
returning another single cursor for the response, sorting by subject in
descending order, returning the author, subject, and summary fields as well
as a snippeted field content.
results = index.search(
query=Query(\'subject:first good\',
options=QueryOptions(limit=20,
cursor=Cursor(),
sort_options=SortOptions(
expressions=[SortExpression(expression=\'subject\')],
limit=1000),
returned_fields=[\'author\', \'subject\', \'summary\'],
snippeted_fields=[\'content\'])))
The following code fragment shows how to use a results cursor
cursor = results.cursor
for result in results:
# process result
results = index.search(
Query(\'subject:first good\', options=QueryOptions(cursor=cursor)))
The following code fragment shows how to use a per_result cursor
results = index.search(
query=Query(\'subject:first good\',
options=QueryOptions(limit=20,
cursor=Cursor(per_result=True),
cursor = None
for result in results:
cursor = result.cursor
results = index.search(
Query(\'subject:first good\', options=QueryOptions(cursor=cursor)))
See http://developers.google.com/appengine/docs/python/search/query_strings
for more information about query syntax.
Args:
query: The Query to match against documents in the index.
Kwargs:
deadline: Deadline for RPC call in seconds; if None use the default.
Returns:
A SearchResults containing a list of documents matched, number returned
and number matched by the query.
Raises:
TypeError: If any of the parameters have invalid types, or an unknown
attribute is passed.
ValueError: If any of the parameters have invalid values (e.g., a
negative deadline).'

@datastore_rpc._positional(2)
def search(self, query, deadline=None, **kwargs):

    return self.search_async(query, deadline=deadline, **kwargs).get_result()
