google.appengine.api.search.Document

Represents a user generated document.

Inherits From: expected_type

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 The visible printable ASCII string identifying the document which does not start with '!'. Whitespace is excluded from ids. If no id is provided, the search service will provide one.
fields An iterable of Field instances representing the content of the document.
language The code of the language used in the field values.
rank The rank of this document used to specify the order in which documents are returned by search. Rank must be a non-negative integer. If not specified, the number of seconds since 1st Jan 2011 is used. Documents are returned in descending order of their rank, in absence of sorting or scoring options.
facets An iterable of Facet instances representing the facets for this document.

TypeError If any of the parameters have invalid types, or an unknown attribute is passed.
ValueError If any of the parameters have invalid values.

doc_id Returns the document identifier.
facets Returns a list of facets of the document.
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.

Methods

facet

View source

Returns list of facets with the provided name.

Args
facet_name The name of the facet to return.

Returns
A list of facets with the given name.

field

View source

Returns the field with the provided field name.

Args
field_name The name of the field to return.

Returns
A field with the given name.

Raises
ValueError There is not exactly one field with the given name.

__eq__

View source

Return self==value.

__getitem__

View source

Returns a list of all fields with the provided field name.

Args
field_name The name of the field to return.

Returns
All fields with the given name, or an empty list if no field with that name exists.

__iter__

View source

Documents do not support iteration.

This is provided to raise an explicit exception.

__ne__

View source

Return self!=value.