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')
Args
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.
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.
Attributes
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-04-26 UTC."],[[["The `Document` class represents a user-generated document in the search service, which can include a document ID, fields, language, rank, and facets."],["Documents can be created with a custom `doc_id`, or if omitted, the search service will assign one automatically, but it must be a visible printable ASCII string that does not start with '!'."],["The document `rank` determines the order in which documents are returned, with a default rank being the number of seconds since January 1st, 2011 if not otherwise specified."],["The `field` method retrieves a single field by name, while `facet` retrieves facets by name, and the `__getitem__` method can retrieve all fields with a specified name."],["Attributes such as `doc_id`, `fields`, `language`, `rank`, and `facets` can be accessed to get information about a given document."]]],[]]