Package xappy :: Module searchconnection :: Class SearchResult
[frames] | no frames]

Class SearchResult

source code

                      object --+    
                               |    
datastructures.ProcessedDocument --+
                                   |
                                  SearchResult

A result from a search.

As well as being a ProcessedDocument representing the document in the database, the result has several members which may be used to get information about how well the document matches the search:



Instance Methods
 
__init__(self, msetitem, results)
Create a ProcessedDocument.
source code
 
summarise(self, field, maxlen=600, hl=('<b>', '</b>'), query=None)
Return a summarised version of the field specified.
source code
 
highlight(self, field, hl=('<b>', '</b>'), strip_tags=False, query=None)
Return a highlighted version of the field specified.
source code
 
__repr__(self)
repr(x)
source code

Inherited from datastructures.ProcessedDocument: add_term, add_value, get_value, prepare

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__

Properties

Inherited from datastructures.ProcessedDocument: data, id

Inherited from object: __class__

Method Details

__init__(self, msetitem, results)
(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: datastructures.ProcessedDocument.__init__
(inherited documentation)

summarise(self, field, maxlen=600, hl=('<b>', '</b>'), query=None)

source code 

Return a summarised version of the field specified.

This will return a summary of the contents of the field stored in the search result, with words which match the query highlighted.

The maximum length of the summary (in characters) may be set using the maxlen parameter.

The return value will be a string holding the summary, with highlighting applied. If there are multiple instances of the field in the document, the instances will be joined with a newline character.

To turn off highlighting, set hl to None. Each highlight will consist of the first entry in the hl list being placed before the word, and the second entry in the hl list being placed after the word.

Any XML or HTML style markup tags in the field will be stripped before the summarisation algorithm is applied.

If query is supplied, it should contain a Query object, as returned from SearchConnection.query_parse() or related methods, which will be used as the basis of the summarisation and highlighting rather than the query which was used for the search.

Raises KeyError if the field is not known.

highlight(self, field, hl=('<b>', '</b>'), strip_tags=False, query=None)

source code 

Return a highlighted version of the field specified.

This will return all the contents of the field stored in the search result, with words which match the query highlighted.

The return value will be a list of strings (corresponding to the list of strings which is the raw field data).

Each highlight will consist of the first entry in the hl list being placed before the word, and the second entry in the hl list being placed after the word.

If strip_tags is True, any XML or HTML style markup tags in the field will be stripped before highlighting is applied.

If query is supplied, it should contain a Query object, as returned from SearchConnection.query_parse() or related methods, which will be used as the basis of the summarisation and highlighting rather than the query which was used for the search.

Raises KeyError if the field is not known.

__repr__(self)
(Representation operator)

source code 
repr(x)
Overrides: datastructures.ProcessedDocument.__repr__