App Engine Python SDK  v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
Public Member Functions | List of all members
google.appengine.api.search.search.QueryOptions Class Reference
Inheritance diagram for google.appengine.api.search.search.QueryOptions:

Public Member Functions

def __init__
 
def limit
 
def number_found_accuracy
 
def cursor
 
def offset
 
def sort_options
 
def returned_fields
 
def ids_only
 
def snippeted_fields
 
def returned_expressions
 
def __repr__
 

Detailed Description

Options for post-processing results for a query.

Options include the ability to sort results, control which document fields
to return, produce snippets of fields and compute and sort by complex
scoring expressions.

If you wish to randomly access pages of search results, you can use an
offset:

# get the first set of results
page_size = 10
results = index.search(Query(query_string='some stuff',
    QueryOptions(limit=page_size))

# calculate pages
pages = results.found_count / page_size

# user chooses page and hence an offset into results
next_page = ith * page_size

# get the search results for that page
results = index.search(Query(query_string='some stuff',
    QueryOptions(limit=page_size, offset=next_page))

Constructor & Destructor Documentation

def google.appengine.api.search.search.QueryOptions.__init__ (   self,
  limit = 20,
  number_found_accuracy = None,
  cursor = None,
  offset = None,
  sort_options = None,
  returned_fields = None,
  ids_only = False,
  snippeted_fields = None,
  returned_expressions = None 
)
Initializer.

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 SearchResults, 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'])))

Args:
  limit: The limit on number of documents to return in results.
  number_found_accuracy: The minimum accuracy requirement for
SearchResults.number_found. If set, the number_found will be
accurate up to at least that number. For example, when set to 100,
any SearchResults with number_found <= 100 is accurate. This option
may add considerable latency/expense, especially when used with
returned_fields.
  cursor: A Cursor describing where to get the next set of results,
or to provide next cursors in SearchResults.
  offset: The offset is number of documents to skip in search results. This
is an alternative to using a query cursor, but allows random access into
the results. Using offsets rather than cursors are more expensive. You
can only use either cursor or offset, but not both. Using an offset
means that no cursor is returned in SearchResults.cursor, nor in each
ScoredDocument.cursor.
  sort_options: A SortOptions specifying a multi-dimensional sort over
search results.
  returned_fields: An iterable of names of fields to return in search
results.
  ids_only: Only return document ids, do not return any fields.
  snippeted_fields: An iterable of names of fields to snippet and return
in search result expressions.
  returned_expressions: An iterable of FieldExpression to evaluate and
return in search results.
Raises:
  TypeError: If an unknown iterator_options or sort_options is passed.
  ValueError: If ids_only and returned_fields are used together.
  ExpressionError: If one of the returned expression strings is not
parseable.

Member Function Documentation

def google.appengine.api.search.search.QueryOptions.cursor (   self)
Returns the Cursor for the query.
def google.appengine.api.search.search.QueryOptions.ids_only (   self)
Returns whether to return only document ids in search results.
def google.appengine.api.search.search.QueryOptions.limit (   self)
Returns a limit on number of documents to return in results.
def google.appengine.api.search.search.QueryOptions.number_found_accuracy (   self)
Returns minimum accuracy requirement for SearchResults.number_found.
def google.appengine.api.search.search.QueryOptions.offset (   self)
Returns the number of documents in search results to skip.
def google.appengine.api.search.search.QueryOptions.returned_expressions (   self)
Returns iterable of FieldExpression to return in results.
def google.appengine.api.search.search.QueryOptions.returned_fields (   self)
Returns an iterable of names of fields to return in search results.
def google.appengine.api.search.search.QueryOptions.snippeted_fields (   self)
Returns iterable of field names to snippet and return in results.
def google.appengine.api.search.search.QueryOptions.sort_options (   self)
Returns a SortOptions.

The documentation for this class was generated from the following file: