Returns the code of the language the content in value is written in.
Returns the name of the field.
Returns the value of the field.
Bases: object
Represents an expression that will be computed for each result returned.
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’.
Returns a string containing an expression returned in search results.
Returns name of the expression to return in search results.
Bases: google.appengine.api.search.search.Field
A Field that has HTML content.
HtmlField(name=’content’, value=’<html>herbata, kawa</html>’, language=’pl’)
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))
Bases: object
Represents a point on the Earth’s surface, in lat, long coordinates.
Returns the angle between equatorial plan and line thru the geo point.
Returns the angle from a reference meridian to another meridian.
Returns a list of available indexes.
Parametersnamespace – 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.
deadline: Deadline for RPC call in seconds; if None use the default.
The GetResponse containing a list of available indexes.
RaisesInternalError – 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).
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.
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
Returns a list of results ordered by Id from the index.
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’,
value=’<html>some content here</html>’)])
# Index the document. try:
index.put(doc)
# 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
# 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.
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.
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.
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.
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.
Retrieve a document by document ID.
Parametersdoc_id – The ID of the document to retreive.
deadline: Deadline for RPC call in seconds; if None use the default.
If the document ID exists, returns the associated document. Otherwise, returns None.
RaisesTypeError – 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).
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 a range of Documents in the index, in id order.
Parametersstart_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.
deadline: Deadline for RPC call in seconds; if None use the default.
A GetResponse containing a list of Documents, ordered by Id.
RaisesError – 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).
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.
Returns the name of the index.
Returns the namespace of the name of the index.
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.
deadline: Deadline for RPC call in seconds; if None use the default.
A list of PutResult, one per Document requested to be indexed.
RaisesPutError – 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.
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.
Returns the schema mapping field names to list of types supported.
Only valid for Indexes returned by search.get_indexes method.
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.
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
Query(‘subject:first good’, options=QueryOptions(cursor=cursor)))
The following code fragment shows how to use a per_result cursor
cursor=Cursor(per_result=True), …)))
cursor = None for result in results:
cursor = result.cursor
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.
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.
RaisesTypeError – 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).
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.
Returns the source of the index.
Deprecated: from 1.7.6, source is no longer available.
The maximum allowable storage for this index, in bytes.
Returns None for indexes not obtained from search.get_indexes.
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.
Bases: google.appengine.api.search.search.Error
Indicates a call on the search API has failed on the internal backend.
Bases: google.appengine.api.search.search.Error
Indicates an invalid request was made on the search API by the client.
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:
expression=’_score’, direction=search.SortExpression.ASCENDING, default_value=0.0)])
The scores in this case will be negative.
Bases: google.appengine.api.search.search.Field
A Field that has a numeric value.
NumberField(name=’size’, value=10)
Bases: google.appengine.api.search.search.Facet
A Facet that has a numeric value.
NumberFacet(name=’wine_vintage’, value=2000)
Bases: object
Represents result of individual operation of a batch index or removal.
This is an abstract class.
Returns the code indicating the status of the operation.
Returns the Id of the object the operation was performed on.
Returns any associated error message if the operation was in error.
Bases: google.appengine.api.search.search.Error
Indicates some error occurred indexing one of the objects requested.
Returns PutResult list corresponding to objects indexed.
Bases: google.appengine.api.search.search.OperationResult
The result of indexing a single object.
Bases: object
Represents a request on the search service to query the index.
Returns true if facet disocery is on.
Returns FacetOptions defining processing of facets.
Returns list of facet refinements.
Returns QueryOptions defining post-processing on the search results.
Returns the query string to be applied to search service.
Returns the list of specific facets to be included with the result.
Bases: google.appengine.api.search.search.Error
An error occurred while parsing a query input string.
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))
Returns the Cursor for the query.
Returns whether to return only document ids in search results.
Returns a limit on number of documents to return in results.
Returns minimum accuracy requirement for SearchResults.number_found.
Returns the number of documents in search results to skip.
Returns iterable of FieldExpression to return in results.
Returns an iterable of names of fields to return in search results.
Returns iterable of field names to snippet and return in results.
Returns a SortOptions.
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:
expression=’_score’, direction=search.SortExpression.ASCENDING, default_value=0.0)])
The scores in this case will be negative.
Bases: google.appengine.api.search.search.Document
Represents a scored document returned from a search.
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.
The list of computed fields the result of expression evaluation.
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.
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.
Bases: object
Represents the result of executing a search request.
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.
Return the list of FacetResults that found in matched documents.
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.
Returns the list of ScoredDocuments that matched the query.
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.
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.
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’)
Returns a default value for the expression if no value computed.
Returns the direction to sort expression – ASCENDING or DESCENDING.
Returns the expression to sort by.
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:
direction=SortExpression.DESCENDING, default_value=0),
direction=SortExpression.ASCENDING, default_value=999999.99)],
limit=1000)
A list of SortExpression specifying a multi-dimensional sort.
Returns the limit on the number of documents to score or sort.
Returns a match scorer to score documents with.
Bases: google.appengine.api.search.search.Field
A Field that has text content.
TextField(name=’signature’, value=’brzydka pogoda’, language=’pl’)
Bases: google.appengine.api.search.search.Error
Indicates a call on the search API could not finish before its deadline.
Bases: google.appengine.api.search.search.Field
A field that matches searches on prefixes of its individual terms.
TokenizedPrefixField(name=’title’, value=’Goodwill Hunting’)
Bases: google.appengine.api.search.search.Error
Indicates a call on the search API has failed, but retrying may succeed.
Bases: google.appengine.api.search.search.Field
A field that matches searches on prefixes of the whole field.
UntokenizedPrefixField(name=’title’, value=’how to swim freestyle’)
Bases: google.appengine.api.search.search.Field
A vector field that can be used in a dot product expression.
VectorField(name=’scores’, value=[1, 2, 3])
dot(scores, vector(3, 2, 1))
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-04-04 UTC.