google.appengine.api.search.search module
Summary
A Python Search API used by app developers.
Contains methods used to interface with Search API. Contains API classes that forward to apiproxy.
Contents
- class google.appengine.api.search.search.AtomField(name, value=None, language=None)source
-
Bases: google.appengine.api.search.search.Field
A Field that has content to be treated as a single token for indexing.
- The following example shows an atom field named contributor:
-
AtomField(name='contributor', value='foo@bar.com')
- class google.appengine.api.search.search.AtomFacet(name, value=None)source
-
Bases: google.appengine.api.search.search.Facet
A Facet that has content to be treated as a single token for indexing.
- The following example shows an atom facet named wine_type:
-
AtomFacet(name=’wine_type’, value=’Red’)
- exception google.appengine.api.search.search.ConcurrentTransactionErrorsource
-
Bases: google.appengine.api.search.search.Error
Indicates a call on the search API failed due to concurrent updates.
- class google.appengine.api.search.search.Cursor(web_safe_string=None, per_result=False)source
-
Bases: object
Specifies how to get the next page of results in a search.
A cursor returned in a previous set of search results to use as a starting point to retrieve the next set of results. This can get you better performance, and also improves the consistency of pagination through index updates.
The following shows how to use the cursor to get the next page of results:
# get the first set of results; the first cursor is used to specify # that cursors are to be returned in the SearchResults. results = index.search(Query(query_string=’some stuff’,
QueryOptions(cursor=Cursor()))
# get the next set of results results = index.search(Query(query_string=’some stuff’,
QueryOptions(cursor=results.cursor)))
If you want to continue search from any one of the ScoredDocuments in SearchResults, then you can set Cursor.per_result to True.
# get the first set of results; the first cursor is used to specify # that cursors are to be returned in the SearchResults. results = index.search(Query(query_string=’some stuff’,
QueryOptions(cursor=Cursor(per_result=True)))
# this shows how to access the per_document cursors returned from a search per_document_cursor = None for scored_document in results:
per_document_cursor = scored_document.cursor
# get the next set of results results = index.search(Query(query_string=’some stuff’,
QueryOptions(cursor=per_document_cursor)))
- per_result
-
Returns whether to return a cursor for each ScoredDocument in results.
- web_safe_string
-
Returns the cursor string generated by the search service.
- class google.appengine.api.search.search.DateField(name, value=None)source
-
Bases: google.appengine.api.search.search.Field
A Field that has a date or datetime value.
Only Python “naive” date or datetime values may be used (not “aware” values).
- The following example shows a date field named creation_date:
-
DateField(name=’creation_date’, value=datetime.date(2011, 03, 11))
- exception google.appengine.api.search.search.DeleteError(message, results)source
-
Bases: google.appengine.api.search.search.Error
Indicates some error occured deleting one of the objects requested.
- results
-
Returns DeleteResult list corresponding to Documents deleted.
- class google.appengine.api.search.search.DeleteResult(code, message=None, id=None)source
-
Bases: google.appengine.api.search.search.OperationResult
The result of deleting a single document.
- class google.appengine.api.search.search.Document(doc_id=None, fields=None, language='en', rank=None, facets=None)source
-
Bases: object
Represents a user generated document.
The following example shows how to create a document consisting of a set of fields, some plain text and some in HTML.
- Document(doc_id=’document_id’,
-
- fields=[TextField(name=’subject’, value=’going for dinner’),
-
- HtmlField(name=’body’,
-
value=’<html>I found a place.</html>’),
- TextField(name=’signature’, value=’brzydka pogoda’,
-
language=’pl’)],
- facets=[AtomFacet(name=’tag’, value=’food’),
-
NumberFacet(name=’priority’, value=5.0)],
language=’en’)
- doc_id
-
Returns the document identifier.
- facet(facet_name)source
Returns list of facets with the provided name.
Parametersfacet_name – The name of the facet to return.
ReturnsA list of facets with the given name.
- facets
-
Returns a list of facets of the document.
- field(field_name)source
Returns the field with the provided field name.
Parametersfield_name – The name of the field to return.
ReturnsA field with the given name.
RaisesValueError – There is not exactly one field with the given name.
- fields
-
Returns a list of fields of the document.
- language
-
Returns the code of the language the document fields are written in.
- rank
-
Returns the rank of this document.
- exception google.appengine.api.search.search.Errorsource
-
Bases: exceptions.Exception
Indicates a call on the search API has failed.
- exception google.appengine.api.search.search.ExpressionErrorsource
-
Bases: google.appengine.api.search.search.Error
An error occurred while parsing an expression input string.
- class google.appengine.api.search.search.Facet(name, value)source
-
Bases: object
An abstract base class which represents a facet of a document.
This class should not be directly instantiated.
- name
-
Returns the name of the facet.
- value
-
Returns the value of the facet.
- class google.appengine.api.search.search.FacetOptions(*args, **kwds)source
-
Bases: object
Options for processing facet reults of a query.
- depth
-
Returns the number of documents to analyze for facet discovery.
- discovery_limit
-
Returns the number of facets to discover.
- discovery_value_limit
-
Returns the number of values to discover for each facet.
- class google.appengine.api.search.search.FacetRange(*args, **kwds)source
-
Bases: object
A facet range with start and end values.
An example of a FacetRange for good rating is: FacetRange(start=3.0, end=3.5)
- end
-
Returns exclusive end of the range.
- start
-
Returns inclusive start of the range.
- class google.appengine.api.search.search.FacetRefinement(*args, **kwds)source
-
Bases: object
A Facet Refinement to filter out search results based on a facet value.
NOTE: The recommended way to use facet refinement is to use the token string. Each FacetResult will have a token that is acceptable instead of this class. To provide manual FacetRefinement, an instance of this class can be passed to SearchOptions. NOTE: that either value or facet_range should be set but not both. Example: Request for a range refinement for a numeric facet:
FacetRefinement(name=’rating’, facet_range=FacetRange(start=1.0,end=2.5))
- static FromTokenString(token_string)source
Converts a token string to a FacetRefinement object.
Do not store token strings between different versions of API as key could be incompatible.
Parameters-
token_string – A token string created by ToTokenString method or returned
-
a search result. (by) –
A FacetRefinement object.
RaisesValueError – If the token_string is invalid.
-
- ToTokenString()source
Converts this refinement to a token string safe to be used in HTML.
The format of this string may change.
ReturnsA token string safe to be used in HTML for this facet refinement.
- facet_range
-
Returns range of the facet refinement.
- name
-
Returns name of the facet refinement.
- value
-
Returns value of the facet refinement.
- class google.appengine.api.search.search.FacetRequest(*args, **kwds)source
-
Bases: object
A facet to be included in search result.
- An example of a request for a facet only with name:
-
FacetRequest(‘ExpediteShipping’)
(in that case, results will always have this facet) Or with a value constraint:
FacetRequest(‘Size’, values=[‘XL’,’L’,’M’]
(results will have this facet with only specified values) Or ranges:
- FacetRequest(‘Rating’, ranges=[
-
FacetRange(1.0, 2.0), FacetRange(2.0, 3.5), FacetRange(3.5, 4.0)]
(results will have this facet with specified ranges)
- name
-
Returns the name of the facet.
- ranges
-
Returns FacetRanges of values to be included in the result.
- value_limit
-
Returns number of values to be included in the result.
- values
-
Returns specific values to be included in the result.
- class google.appengine.api.search.search.FacetResult(name, values=None)source
-
Bases: object
Represents a facet result returned from a search with faceted search.
- name
-
Returns the name of this facet result.
- values
-
Returns values for this facet result.
- class google.appengine.api.search.search.FacetResultValue(label, count, refinement)source
-
Bases: object
A facet value as part of search result.
- count
-
Returns the count for this facet value.
- label
-
Returns the label for this facet value.
- refinement_token
-
Returns the refinement token string for this facet value.
- class google.appengine.api.search.search.Field(name, value, language=None)source
-
Bases: object
An abstract base class which represents a field of a document.
This class should not be directly instantiated.
- ATOM = 'ATOM'
- DATE = 'DATE'
- GEO_POINT = 'GEO_POINT'
- HTML = 'HTML'
- NUMBER = 'NUMBER'
- TEXT = 'TEXT'
- TOKENIZED_PREFIX = 'TOKENIZED_PREFIX'
- UNTOKENIZED_PREFIX = 'UNTOKENIZED_PREFIX'
- VECTOR = 'VECTOR'
- language
-
Returns the code of the language the content in value is written in.
- name
-
Returns the name of the field.
- value
-
Returns the value of the field.
- class google.appengine.api.search.search.FieldExpression(name, expression)source
-
Bases: object
Represents an expression that will be computed for each result returned.
- For example,
-
- FieldExpression(name=’content_snippet’,
-
expression=’snippet(“very important”, content)’)
means a computed field ‘content_snippet’ will be returned with each search result, which contains HTML snippets of the ‘content’ field which match the query ‘very important’.
- MAXIMUM_EXPRESSION_LENGTH = 1000
- MAXIMUM_OPERATOR_LENGTH = 100
- expression
-
Returns a string containing an expression returned in search results.
- name
-
Returns name of the expression to return in search results.
- class google.appengine.api.search.search.HtmlField(name, value=None, language=None)source
-
Bases: google.appengine.api.search.search.Field
A Field that has HTML content.
- The following example shows an html field named content:
-
HtmlField(name=’content’, value=’<html>herbata, kawa</html>’, language=’pl’)
- class google.appengine.api.search.search.GeoField(name, value=None)source
-
Bases: google.appengine.api.search.search.Field
A Field that has a GeoPoint value.
The following example shows a geo field named place:
GeoField(name=’place’, value=GeoPoint(latitude=-33.84, longitude=151.26))
- class google.appengine.api.search.search.GeoPoint(latitude, longitude)source
-
Bases: object
Represents a point on the Earth’s surface, in lat, long coordinates.
- latitude
-
Returns the angle between equatorial plan and line thru the geo point.
- longitude
-
Returns the angle from a reference meridian to another meridian.
- google.appengine.api.search.search.get_indexes(*args, **kwds)source
Returns a list of available indexes.
Parameters-
namespace – The namespace of indexes to be returned. If not set then the current namespace is used.
-
offset – The offset of the first returned index.
-
limit – The number of indexes to return.
-
start_index_name – The name of the first index to be returned.
-
include_start_index – Whether or not to return the start index.
-
index_name_prefix – The prefix used to select returned indexes.
-
fetch_schema – Whether to retrieve Schema for each Index or not.
- Kwargs:
-
deadline: Deadline for RPC call in seconds; if None use the default.
The GetResponse containing a list of available indexes.
Raises-
InternalError – If the request fails on internal servers.
-
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).
-
- google.appengine.api.search.search.get_indexes_async(*args, **kwds)source
-
Asynchronously returns a list of available indexes.
Identical to get_indexes() except that it returns a future. Call get_result() on the return value to block on the call and get its result.
- class google.appengine.api.search.search.GetResponse(results=None)source
-
Bases: object
Represents the result of executing a get request.
For example, the following code shows how a response could be used to determine which documents were successfully removed or not.
response = index.get_range() for document in response:
print “document “, document
- results
-
Returns a list of results ordered by Id from the index.
- class google.appengine.api.search.search.Index(name, namespace=None, source='SEARCH')source
-
Bases: object
Represents an index allowing indexing, deleting and searching documents.
The following code fragment shows how to add documents, then search the index for documents matching a query.
# Get the index. index = Index(name=’index-name’)
# Create a document. doc = Document(doc_id=’document-id’,
- fields=[TextField(name=’subject’, value=’my first email’),
-
- HtmlField(name=’body’,
-
value=’<html>some content here</html>’)])
# Index the document. try:
index.put(doc)
- except search.Error, e:
-
# possibly retry indexing or log error
# Query the index. try:
results = index.search(‘subject:first body:here’)
# Iterate through the search results. for scored_document in results:
print scored_document
- except search.Error, e:
-
# possibly log the failure
Once an index is created with a given specification, that specification is immutable.
Search results may contain some out of date documents. However, any two changes to any document stored in an index are applied in the correct order.
- CLOUD_STORAGE = 'CLOUD_STORAGE'
- DATASTORE = 'DATASTORE'
- RESPONSE_CURSOR = 'RESPONSE_CURSOR'
- RESULT_CURSOR = 'RESULT_CURSOR'
- SEARCH = 'SEARCH'
- delete(*args, **kwds)source
Delete the documents with the corresponding document ids from the index.
If no document exists for the identifier in the list, then that document identifier is ignored.
Parametersdocument_ids – A single identifier or list of identifiers of documents to delete.
- Kwargs:
-
deadline: Deadline for RPC call in seconds; if None use the default.
-
DeleteError – If one or more documents failed to remove or number removed did not match requested.
-
ValueError – If document_ids is not a string or iterable of valid document identifiers or number of document ids is larger than MAXIMUM_DOCUMENTS_PER_PUT_REQUEST or deadline is a negative number.
- delete_async(*args, **kwds)source
-
Asynchronously deletes the documents with the corresponding document ids.
Identical to delete() except that it returns a future. Call get_result() on the return value to block on the call and get its result.
- delete_schema()source
Deprecated in 1.7.4. Delete the schema from the index.
We are deprecating this method and replacing with more general schema and index managment.
A possible use may be remove typed fields which are no longer used. After you delete the schema, you need to index one or more documents to rebuild the schema. Until you re-index some documents, searches may fail, especially searches using field restricts.
RaisesDeleteError – If the schema failed to be deleted.
- get(*args, **kwds)source
Retrieve a document by document ID.
Parametersdoc_id – The ID of the document to retreive.
- Kwargs:
-
deadline: Deadline for RPC call in seconds; if None use the default.
If the document ID exists, returns the associated document. Otherwise, returns None.
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).
- get_async(*args, **kwds)source
-
Asynchronously retrieve a document by document ID.
Identical to get() except that it returns a future. Call get_result() on the return value to block on the call and get its result.
- get_range(*args, **kwds)source
Get a range of Documents in the index, in id order.
Parameters-
start_id – String containing the Id from which to list Documents from. By default, starts at the first Id.
-
include_start_object – If true, include the Document with the Id specified by the start_id parameter.
-
limit – The maximum number of Documents to return.
-
ids_only – If true, the Documents returned only contain their keys.
- Kwargs:
-
deadline: Deadline for RPC call in seconds; if None use the default.
A GetResponse containing a list of Documents, ordered by Id.
Raises-
Error – Some subclass of Error is raised if an error occurred processing the request.
-
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).
-
- get_range_async(*args, **kwds)source
-
Asynchronously gets a range of Documents in the index, in id order.
Identical to get_range() except that it returns a future. Call get_result() on the return value to block on the call and get its result.
- name
-
Returns the name of the index.
- namespace
-
Returns the namespace of the name of the index.
- put(*args, **kwds)source
Index the collection of documents.
If any of the documents are already in the index, then reindex them with their corresponding fresh document.
Parametersdocuments – A Document or iterable of Documents to index.
- Kwargs:
-
deadline: Deadline for RPC call in seconds; if None use the default.
A list of PutResult, one per Document requested to be indexed.
Raises-
PutError – If one or more documents failed to index or number indexed did not match requested.
-
TypeError – If an unknown attribute is passed.
-
ValueError – If documents is not a Document or iterable of Document or number of the documents is larger than MAXIMUM_DOCUMENTS_PER_PUT_REQUEST or deadline is a negative number.
- put_async(*args, **kwds)source
-
Asynchronously indexes the collection of documents.
Identical to put() except that it returns a future. Call get_result() on the return value to block on the call and get its result.
- schema
-
Returns the schema mapping field names to list of types supported.
Only valid for Indexes returned by search.get_indexes method.
- search(*args, **kwds)source
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.
Parametersquery – The Query to match against documents in the index.
- Kwargs:
-
deadline: Deadline for RPC call in seconds; if None use the default.
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).
- search_async(*args, **kwds)source
-
Asynchronously searches the index for documents matching the query.
Identical to search() except that it returns a future. Call get_result() on the return value to block on the call and get its result.
- source
-
Returns the source of the index.
Deprecated: from 1.7.6, source is no longer available.
- storage_limit
-
The maximum allowable storage for this index, in bytes.
Returns None for indexes not obtained from search.get_indexes.
- storage_usage
-
The approximate number of bytes used by this index.
The number may be slightly stale, as it may not reflect the results of recent changes.
Returns None for indexes not obtained from search.get_indexes.
- exception google.appengine.api.search.search.InternalErrorsource
-
Bases: google.appengine.api.search.search.Error
Indicates a call on the search API has failed on the internal backend.
- exception google.appengine.api.search.search.InvalidRequestsource
-
Bases: google.appengine.api.search.search.Error
Indicates an invalid request was made on the search API by the client.
- class google.appengine.api.search.search.MatchScorersource
-
Bases: object
Assigns a document score based on term frequency.
If you add a MatchScorer to a SortOptions as in the following code:
sort_opts = search.SortOptions(match_scorer=search.MatchScorer())
then, this will sort the documents in descending score order. The scores will be positive. If you want to sort in ascending order, then use the following code:
- sort_opts = search.SortOptions(match_scorer=search.MatchScorer(),
-
- expressions=[search.SortExpression(
-
expression=’_score’, direction=search.SortExpression.ASCENDING, default_value=0.0)])
The scores in this case will be negative.
- class google.appengine.api.search.search.NumberField(name, value=None)source
-
Bases: google.appengine.api.search.search.Field
A Field that has a numeric value.
- The following example shows a number field named size:
-
NumberField(name=’size’, value=10)
- class google.appengine.api.search.search.NumberFacet(name, value=None)source
-
Bases: google.appengine.api.search.search.Facet
A Facet that has a numeric value.
- The following example shows a number facet named wine_vintage:
-
NumberFacet(name=’wine_vintage’, value=2000)
- class google.appengine.api.search.search.OperationResult(code, message=None, id=None)source
-
Bases: object
Represents result of individual operation of a batch index or removal.
This is an abstract class.
- CONCURRENT_TRANSACTION = 'CONCURRENT_TRANSACTION'
- INTERNAL_ERROR = 'INTERNAL_ERROR'
- INVALID_REQUEST = 'INVALID_REQUEST'
- OK = 'OK'
- TIMEOUT = 'TIMEOUT'
- TRANSIENT_ERROR = 'TRANSIENT_ERROR'
- code
-
Returns the code indicating the status of the operation.
- id
-
Returns the Id of the object the operation was performed on.
- message
-
Returns any associated error message if the operation was in error.
- exception google.appengine.api.search.search.PutError(message, results)source
-
Bases: google.appengine.api.search.search.Error
Indicates some error occurred indexing one of the objects requested.
- results
-
Returns PutResult list corresponding to objects indexed.
- class google.appengine.api.search.search.PutResult(code, message=None, id=None)source
-
Bases: google.appengine.api.search.search.OperationResult
The result of indexing a single object.
- class google.appengine.api.search.search.Query(*args, **kwds)source
-
Bases: object
Represents a request on the search service to query the index.
- enable_facet_discovery
-
Returns true if facet disocery is on.
- facet_options
-
Returns FacetOptions defining processing of facets.
- facet_refinements
-
Returns list of facet refinements.
- options
-
Returns QueryOptions defining post-processing on the search results.
- query_string
-
Returns the query string to be applied to search service.
- return_facets
-
Returns the list of specific facets to be included with the result.
- exception google.appengine.api.search.search.QueryErrorsource
-
Bases: google.appengine.api.search.search.Error
An error occurred while parsing a query input string.
- class google.appengine.api.search.search.QueryOptions(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)source
-
Bases: object
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))
- cursor
-
Returns the Cursor for the query.
- ids_only
-
Returns whether to return only document ids in search results.
- limit
-
Returns a limit on number of documents to return in results.
- number_found_accuracy
-
Returns minimum accuracy requirement for SearchResults.number_found.
- offset
-
Returns the number of documents in search results to skip.
- returned_expressions
-
Returns iterable of FieldExpression to return in results.
- returned_fields
-
Returns an iterable of names of fields to return in search results.
- snippeted_fields
-
Returns iterable of field names to snippet and return in results.
- sort_options
-
Returns a SortOptions.
- class google.appengine.api.search.search.RescoringMatchScorersource
-
Bases: google.appengine.api.search.search.MatchScorer
Assigns a document score based on term frequency weighted by doc parts.
If you add a RescoringMatchScorer to a SortOptions as in the following code:
sort_opts = search.SortOptions(match_scorer=search.RescoringMatchScorer())
then, this will sort the documents in descending score order. The scores will be positive. If you want to sort in ascending order, then use the following code:
- sort_opts = search.SortOptions(match_scorer=search.RescoringMatchScorer(),
-
- expressions=[search.SortExpression(
-
expression=’_score’, direction=search.SortExpression.ASCENDING, default_value=0.0)])
The scores in this case will be negative.
- class google.appengine.api.search.search.ScoredDocument(doc_id=None, fields=None, language='en', sort_scores=None, expressions=None, cursor=None, rank=None, facets=None)source
-
Bases: google.appengine.api.search.search.Document
Represents a scored document returned from a search.
- cursor
A cursor associated with a result, a continued search starting point.
To get this cursor to appear, set the Index.cursor_type to Index.RESULT_CURSOR, otherwise this will be None.
ReturnsThe result cursor.
- expressions
The list of computed fields the result of expression evaluation.
- For example, if a request has
-
FieldExpression(name=’snippet’, ‘snippet(“good story”, content)’)
meaning to compute a snippet field containing HTML snippets extracted from the matching of the query ‘good story’ on the field ‘content’. This means a field such as the following will be returned in expressions for the search result:
HtmlField(name=’snippet’, value=’that was a <b>good story</b> to finish’)
ReturnsThe computed fields.
- sort_scores
Deprecated – the list of scores assigned during sort evaluation.
The right way to retrieve a score is to use ‘_score’ in a FieldExpression.
ReturnsThe list of numeric sort scores.
- class google.appengine.api.search.search.SearchResults(number_found, results=None, cursor=None, facets=None)source
-
Bases: object
Represents the result of executing a search request.
- cursor
Returns a cursor that can be used to continue search from last result.
This corresponds to using a ResultsCursor in QueryOptions, otherwise this will be None.
ReturnsThe results cursor.
- facets
-
Return the list of FacetResults that found in matched documents.
- number_found
Returns the number of documents which were found for the search.
Note that this is an approximation and not an exact count. If QueryOptions.number_found_accuracy parameter is set to 100 for example, then number_found <= 100 is accurate.
ReturnsThe number of documents found.
- results
-
Returns the list of ScoredDocuments that matched the query.
- class google.appengine.api.search.search.SortExpression(expression, direction='DESCENDING', default_value=None)source
-
Bases: object
Sort by a user specified scoring expression.
For example, the following will sort documents on a numeric field named ‘length’ in ascending order, assigning a default value of sys.maxint for documents which do not specify a ‘length’ field.
- SortExpression(expression=’length’,
-
direction=sort.SortExpression.ASCENDING, default_value=sys.maxint)
The following example will sort documents on a date field named ‘published_date’ in descending order, assigning a default value of 1999-12-31 for documents which do not specify a ‘published_date’ field.
- SortExpression(expression=’published_date’,
-
default_value=datetime.date(year=1999, month=12, day=31))
The following example will sort documents on a text field named ‘subject’ in descending order, assigning a default value of ‘’ for documents which do not specify a ‘subject’ field.
SortExpression(expression=’subject’)
- ASCENDING = 'ASCENDING'
- DESCENDING = 'DESCENDING'
- MAX_FIELD_VALUE = u'\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff\U0010ffff'
- MIN_FIELD_VALUE = u''
- default_value
-
Returns a default value for the expression if no value computed.
- direction
-
Returns the direction to sort expression – ASCENDING or DESCENDING.
- expression
-
Returns the expression to sort by.
- class google.appengine.api.search.search.SortOptions(expressions=None, match_scorer=None, limit=1000)source
-
Bases: object
Represents a mulit-dimensional sort of Documents.
The following code shows how to sort documents based on product rating in descending order and then cheapest product within similarly rated products, sorting at most 1000 documents:
- SortOptions(expressions=[
-
- SortExpression(expression=’rating’,
-
direction=SortExpression.DESCENDING, default_value=0),
- SortExpression(expression=’price + tax’,
-
direction=SortExpression.ASCENDING, default_value=999999.99)],
limit=1000)
- expressions
-
A list of SortExpression specifying a multi-dimensional sort.
- limit
-
Returns the limit on the number of documents to score or sort.
- match_scorer
-
Returns a match scorer to score documents with.
- class google.appengine.api.search.search.TextField(name, value=None, language=None)source
-
Bases: google.appengine.api.search.search.Field
A Field that has text content.
- The following example shows a text field named signature with Polish content:
-
TextField(name=’signature’, value=’brzydka pogoda’, language=’pl’)
- exception google.appengine.api.search.search.Timeoutsource
-
Bases: google.appengine.api.search.search.Error
Indicates a call on the search API could not finish before its deadline.
- class google.appengine.api.search.search.TokenizedPrefixField(name, value=None, language=None)source
-
Bases: google.appengine.api.search.search.Field
A field that matches searches on prefixes of its individual terms.
- The following example shows a tokenized prefix field named title:
-
TokenizedPrefixField(name=’title’, value=’Goodwill Hunting’)
- exception google.appengine.api.search.search.TransientErrorsource
-
Bases: google.appengine.api.search.search.Error
Indicates a call on the search API has failed, but retrying may succeed.
- class google.appengine.api.search.search.UntokenizedPrefixField(name, value=None, language=None)source
-
Bases: google.appengine.api.search.search.Field
A field that matches searches on prefixes of the whole field.
- The following example shows an untokenized prefix field named title:
-
UntokenizedPrefixField(name=’title’, value=’how to swim freestyle’)
- class google.appengine.api.search.search.VectorField(name, value=None)source
-
Bases: google.appengine.api.search.search.Field
A vector field that can be used in a dot product expression.
- The following example shows a vector field named scores:
-
VectorField(name=’scores’, value=[1, 2, 3])
- That can be used in a sort/field expression like this:
-
dot(scores, vector(3, 2, 1))