xappy.datastructures.ProcessedDocument

Package xappy :: Module datastructures :: Class ProcessedDocument |
[frames] | no frames]

# Class ProcessedDocument

source code

    object --+
             |
            ProcessedDocument

Known Subclasses:
  searchconnection.SearchResult

A processed document, as stored in the index.

This represents an item which is ready to be stored in the search engine, or which has been returned by the search engine.

Instance Methods
__init__(self, fieldmappings, xapdoc=None) Create a ProcessedDocument. | source code
add_term(self, field, term, wdfinc=1, positions=None) Add a term to the document. | source code
add_value(self, field, value, purpose=`'````'`) Add a value to the document. | source code
get_value(self, field, purpose=`'````'`) Get a value from the document. | source code
prepare(self) Prepare the document for adding to a xapian database. | source code
__repr__(self) repr(x) | source code
Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__str__`

Properties
| data The data stored in this processed document.
| id The unique ID for this document.
Inherited from `object`: `__class__`

Method Details

### __init__(self, fieldmappings, xapdoc=None) (Constructor) | source code
Create a ProcessedDocument. fieldmappings is the configuration from a database connection used lookup the configuration to use to store each field. If supplied, `xapdoc` is a Xapian document to store in the processed document. Otherwise, a new Xapian document is created. Overrides: object.__init__

### add_term(self, field, term, wdfinc=1, positions=None) | source code
Add a term to the document. Terms are the main unit of information used for performing searches. `field` is the field to add the term to. `term` is the term to add. `wdfinc` is the value to increase the within-document-frequency measure for the term by. `positions` is the positional information to add for the term. This may be None to indicate that there is no positional information, or may be an integer to specify one position, or may be a sequence of integers to specify several positions. (Note that the wdf is not increased automatically for each position: if you add a term at 7 positions, and the wdfinc value is 2, the total wdf for the term will only be increased by 2, not by 14.)

### add_value(self, field, value, purpose=`'````'`) | source code
Add a value to the document. Values are additional units of information used when performing searches. Note that values are _not_ intended to be used to store information for display in the search results - use the document data for that. The intention is that as little information as possible is stored in values, so that they can be accessed as quickly as possible during the search operation. Unlike terms, each document may have at most one value in each field (whereas there may be an arbitrary number of terms in a given field). If an attempt to add multiple values to a single field is made, only the last value added will be stored.

### prepare(self) | source code
Prepare the document for adding to a xapian database. This updates the internal xapian document with any changes which have been made, and then returns it.

### __repr__(self) (Representation operator) | source code
repr(x) Overrides: object.__repr__ (inherited documentation)

Property Details

### data The data stored in this processed document. This data is a dictionary of entries, where the key is a fieldname, and the value is a list of strings. Get Method: xappy.datastructures.ProcessedDocument._get_data(self) Set Method: xappy.datastructures.ProcessedDocument._set_data(self, data)

### id The unique ID for this document. Get Method: xappy.datastructures.ProcessedDocument._get_id(self) Set Method: xappy.datastructures.ProcessedDocument._set_id(self, id)