Source code for xapian

# encoding: utf-8
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.13
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.


"""
Xapian is a highly adaptable toolkit which allows developers to easily
add advanced indexing and search facilities to their own applications.
It has built-in support for several families of weighting models
and also supports a rich set of boolean query operators.

In addition to the doc strings provided by this python library, you
may wish to look at the library's overall documentation, either
installed along with the bindings or online at
<https://xapian.org/docs/bindings/python/>, as well as the library's
documentation, possibly installed with the library or with its
development files, or again online at <https://xapian.org/docs/>.
"""



from . import _xapian
from new import instancemethod as new_instancemethod

def _swig_setattr(self, class_type, name, value):
    if (name == "thisown"):
        return self.this.own(value)
    if (name == "this"):
        if type(value).__name__ == 'SwigPyObject':
            self.__dict__[name] = value
            return
    method = class_type.__swig_setmethods__.get(name, None)
    if method:
        return method(self, value)
    object.__setattr__(self, name, value)




def _swig_getattr(self, class_type, name):
    if (name == "thisown"):
        return self.this.own()
    method = class_type.__swig_getmethods__.get(name, None)
    if method:
        return method(self)
    raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))


def _swig_repr(self):
    strthis = ""
    if hasattr(self.this, '__repr__'):
        strthis = "proxy of " + self.this.__repr__()

    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)



from weakref import proxy as weakref_proxy



__version__ = '1.4.11'

class SwigPyIterator(object):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined - class is abstract")
    __repr__ = _swig_repr
    __swig_destroy__ = _xapian.delete_SwigPyIterator
    def __iter__(self):
        return self
SwigPyIterator.value = new_instancemethod(_xapian.SwigPyIterator_value, None, SwigPyIterator)
SwigPyIterator.incr = new_instancemethod(_xapian.SwigPyIterator_incr, None, SwigPyIterator)
SwigPyIterator.decr = new_instancemethod(_xapian.SwigPyIterator_decr, None, SwigPyIterator)
SwigPyIterator.distance = new_instancemethod(_xapian.SwigPyIterator_distance, None, SwigPyIterator)
SwigPyIterator.equal = new_instancemethod(_xapian.SwigPyIterator_equal, None, SwigPyIterator)
SwigPyIterator.copy = new_instancemethod(_xapian.SwigPyIterator_copy, None, SwigPyIterator)
SwigPyIterator.next = new_instancemethod(_xapian.SwigPyIterator_next, None, SwigPyIterator)
SwigPyIterator.__next__ = new_instancemethod(_xapian.SwigPyIterator___next__, None, SwigPyIterator)
SwigPyIterator.previous = new_instancemethod(_xapian.SwigPyIterator_previous, None, SwigPyIterator)
SwigPyIterator.advance = new_instancemethod(_xapian.SwigPyIterator_advance, None, SwigPyIterator)
SwigPyIterator.__eq__ = new_instancemethod(_xapian.SwigPyIterator___eq__, None, SwigPyIterator)
SwigPyIterator.__ne__ = new_instancemethod(_xapian.SwigPyIterator___ne__, None, SwigPyIterator)
SwigPyIterator.__iadd__ = new_instancemethod(_xapian.SwigPyIterator___iadd__, None, SwigPyIterator)
SwigPyIterator.__isub__ = new_instancemethod(_xapian.SwigPyIterator___isub__, None, SwigPyIterator)
SwigPyIterator.__add__ = new_instancemethod(_xapian.SwigPyIterator___add__, None, SwigPyIterator)
SwigPyIterator.__sub__ = new_instancemethod(_xapian.SwigPyIterator___sub__, None, SwigPyIterator)
SwigPyIterator_swigregister = _xapian.SwigPyIterator_swigregister
SwigPyIterator_swigregister(SwigPyIterator)

MSET_DID = _xapian.MSET_DID
MSET_WT = _xapian.MSET_WT
MSET_RANK = _xapian.MSET_RANK
MSET_PERCENT = _xapian.MSET_PERCENT
MSET_DOCUMENT = _xapian.MSET_DOCUMENT
ESET_TNAME = _xapian.ESET_TNAME
ESET_WT = _xapian.ESET_WT
[docs]class Error(Exception): """ All exceptions thrown by Xapian are subclasses of Xapian::Error. This class can not be instantiated directly - instead a subclass should be used. """ __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, Error, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, Error, name) def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined") __repr__ = _swig_repr def get_type(self): """ The type of this error (e.g. "DocNotFoundError".) const char* Xapian::Error::get_type() const """ return _xapian.Error_get_type(self) def get_msg(self): """ Message giving details of the error, intended for human consumption. const std::string& Xapian::Error::get_msg() const """ return _xapian.Error_get_msg(self) def get_context(self): """ Optional context information. const std::string& Xapian::Error::get_context() const This context is intended for use by Xapian::ErrorHandler (for example so it can know which remote server is unreliable and report the problem and remove that server from those being searched). But it's typically a plain-text string, and so also fit for human consumption. """ return _xapian.Error_get_context(self) def get_error_string(self): """ Returns any system error string associated with this exception. const char* Xapian::Error::get_error_string() const The system error string may come from errno, h_errno (on UNIX), or GetLastError() (on MS Windows). If there is no associated system error string, NULL is returned. """ return _xapian.Error_get_error_string(self) __swig_destroy__ = _xapian.delete_Error
Error.get_type = new_instancemethod(_xapian.Error_get_type, None, Error) Error.get_msg = new_instancemethod(_xapian.Error_get_msg, None, Error) Error.get_context = new_instancemethod(_xapian.Error_get_context, None, Error) Error.get_error_string = new_instancemethod(_xapian.Error_get_error_string, None, Error) Error.__str__ = new_instancemethod(_xapian.Error___str__, None, Error) Error_swigregister = _xapian.Error_swigregister Error_swigregister(Error)
[docs]class LogicError(Error): """ The base class for exceptions indicating errors in the program logic. A subclass of LogicError will be thrown if Xapian detects a violation of a class invariant or a logical precondition or postcondition, etc. """ __swig_setmethods__ = {} for _s in [Error]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, LogicError, name, value) __swig_getmethods__ = {} for _s in [Error]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, LogicError, name) def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined") __repr__ = _swig_repr __swig_destroy__ = _xapian.delete_LogicError
LogicError_swigregister = _xapian.LogicError_swigregister LogicError_swigregister(LogicError)
[docs]class RuntimeError(Error): """ The base class for exceptions indicating errors only detectable at runtime. A subclass of RuntimeError will be thrown if Xapian detects an error which is exception derived from RuntimeError is thrown when an error is caused by problems with the data or environment rather than a programming mistake. """ __swig_setmethods__ = {} for _s in [Error]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, RuntimeError, name, value) __swig_getmethods__ = {} for _s in [Error]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, RuntimeError, name) def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined") __repr__ = _swig_repr __swig_destroy__ = _xapian.delete_RuntimeError
RuntimeError_swigregister = _xapian.RuntimeError_swigregister RuntimeError_swigregister(RuntimeError)
[docs]class AssertionError(LogicError): """ AssertionError is thrown if a logical assertion inside Xapian fails. In a debug build of Xapian, a failed assertion in the core library code will cause AssertionError to be thrown. This represents a bug in Xapian (either an invariant, precondition, etc has been violated, or the assertion is incorrect!) """ __swig_setmethods__ = {} for _s in [LogicError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, AssertionError, name, value) __swig_getmethods__ = {} for _s in [LogicError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, AssertionError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::AssertionError::AssertionError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.AssertionError_swiginit(self, _xapian.new_AssertionError(*args)) __swig_destroy__ = _xapian.delete_AssertionError
AssertionError_swigregister = _xapian.AssertionError_swigregister AssertionError_swigregister(AssertionError)
[docs]class InvalidArgumentError(LogicError): """ InvalidArgumentError indicates an invalid parameter value was passed to the API. """ __swig_setmethods__ = {} for _s in [LogicError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, InvalidArgumentError, name, value) __swig_getmethods__ = {} for _s in [LogicError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, InvalidArgumentError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::InvalidArgumentError::InvalidArgumentError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.InvalidArgumentError_swiginit(self, _xapian.new_InvalidArgumentError(*args)) __swig_destroy__ = _xapian.delete_InvalidArgumentError
InvalidArgumentError_swigregister = _xapian.InvalidArgumentError_swigregister InvalidArgumentError_swigregister(InvalidArgumentError)
[docs]class InvalidOperationError(LogicError): """ InvalidOperationError indicates the API was used in an invalid way. """ __swig_setmethods__ = {} for _s in [LogicError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, InvalidOperationError, name, value) __swig_getmethods__ = {} for _s in [LogicError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, InvalidOperationError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::InvalidOperationError::InvalidOperationError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.InvalidOperationError_swiginit(self, _xapian.new_InvalidOperationError(*args)) __swig_destroy__ = _xapian.delete_InvalidOperationError
InvalidOperationError_swigregister = _xapian.InvalidOperationError_swigregister InvalidOperationError_swigregister(InvalidOperationError)
[docs]class UnimplementedError(LogicError): """ UnimplementedError indicates an attempt to use an unimplemented feature. """ __swig_setmethods__ = {} for _s in [LogicError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, UnimplementedError, name, value) __swig_getmethods__ = {} for _s in [LogicError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, UnimplementedError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::UnimplementedError::UnimplementedError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.UnimplementedError_swiginit(self, _xapian.new_UnimplementedError(*args)) __swig_destroy__ = _xapian.delete_UnimplementedError
UnimplementedError_swigregister = _xapian.UnimplementedError_swigregister UnimplementedError_swigregister(UnimplementedError)
[docs]class DatabaseError(RuntimeError): """ DatabaseError indicates some sort of database related error. """ __swig_setmethods__ = {} for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseError, name, value) __swig_getmethods__ = {} for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, DatabaseError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::DatabaseError::DatabaseError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.DatabaseError_swiginit(self, _xapian.new_DatabaseError(*args)) __swig_destroy__ = _xapian.delete_DatabaseError
DatabaseError_swigregister = _xapian.DatabaseError_swigregister DatabaseError_swigregister(DatabaseError)
[docs]class DatabaseCorruptError(DatabaseError): """ DatabaseCorruptError indicates database corruption was detected. """ __swig_setmethods__ = {} for _s in [DatabaseError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseCorruptError, name, value) __swig_getmethods__ = {} for _s in [DatabaseError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, DatabaseCorruptError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::DatabaseCorruptError::DatabaseCorruptError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.DatabaseCorruptError_swiginit(self, _xapian.new_DatabaseCorruptError(*args)) __swig_destroy__ = _xapian.delete_DatabaseCorruptError
DatabaseCorruptError_swigregister = _xapian.DatabaseCorruptError_swigregister DatabaseCorruptError_swigregister(DatabaseCorruptError)
[docs]class DatabaseCreateError(DatabaseError): """ DatabaseCreateError indicates a failure to create a database. """ __swig_setmethods__ = {} for _s in [DatabaseError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseCreateError, name, value) __swig_getmethods__ = {} for _s in [DatabaseError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, DatabaseCreateError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::DatabaseCreateError::DatabaseCreateError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.DatabaseCreateError_swiginit(self, _xapian.new_DatabaseCreateError(*args)) __swig_destroy__ = _xapian.delete_DatabaseCreateError
DatabaseCreateError_swigregister = _xapian.DatabaseCreateError_swigregister DatabaseCreateError_swigregister(DatabaseCreateError)
[docs]class DatabaseLockError(DatabaseError): """ DatabaseLockError indicates failure to lock a database. """ __swig_setmethods__ = {} for _s in [DatabaseError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseLockError, name, value) __swig_getmethods__ = {} for _s in [DatabaseError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, DatabaseLockError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::DatabaseLockError::DatabaseLockError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.DatabaseLockError_swiginit(self, _xapian.new_DatabaseLockError(*args)) __swig_destroy__ = _xapian.delete_DatabaseLockError
DatabaseLockError_swigregister = _xapian.DatabaseLockError_swigregister DatabaseLockError_swigregister(DatabaseLockError)
[docs]class DatabaseModifiedError(DatabaseError): """ DatabaseModifiedError indicates a database was modified. To recover after catching this error, you need to call Xapian::Database::reopen() on the Database and repeat the operation which failed. """ __swig_setmethods__ = {} for _s in [DatabaseError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseModifiedError, name, value) __swig_getmethods__ = {} for _s in [DatabaseError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, DatabaseModifiedError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::DatabaseModifiedError::DatabaseModifiedError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.DatabaseModifiedError_swiginit(self, _xapian.new_DatabaseModifiedError(*args)) __swig_destroy__ = _xapian.delete_DatabaseModifiedError
DatabaseModifiedError_swigregister = _xapian.DatabaseModifiedError_swigregister DatabaseModifiedError_swigregister(DatabaseModifiedError)
[docs]class DatabaseOpeningError(DatabaseError): """ DatabaseOpeningError indicates failure to open a database. """ __swig_setmethods__ = {} for _s in [DatabaseError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseOpeningError, name, value) __swig_getmethods__ = {} for _s in [DatabaseError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, DatabaseOpeningError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::DatabaseOpeningError::DatabaseOpeningError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.DatabaseOpeningError_swiginit(self, _xapian.new_DatabaseOpeningError(*args)) __swig_destroy__ = _xapian.delete_DatabaseOpeningError
DatabaseOpeningError_swigregister = _xapian.DatabaseOpeningError_swigregister DatabaseOpeningError_swigregister(DatabaseOpeningError)
[docs]class DatabaseVersionError(DatabaseOpeningError): """ DatabaseVersionError indicates that a database is in an unsupported format. From time to time, new versions of Xapian will require the database format to be changed, to allow new information to be stored or new optimisations to be performed. Backwards compatibility will sometimes be maintained, so that new versions of Xapian can open old databases, but in some cases Xapian will be unable to open a database because it is in too old (or new) a format. This can be resolved either be upgrading or downgrading the version of Xapian in use, or by rebuilding the database from scratch with the current version of Xapian. """ __swig_setmethods__ = {} for _s in [DatabaseOpeningError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseVersionError, name, value) __swig_getmethods__ = {} for _s in [DatabaseOpeningError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, DatabaseVersionError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::DatabaseVersionError::DatabaseVersionError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.DatabaseVersionError_swiginit(self, _xapian.new_DatabaseVersionError(*args)) __swig_destroy__ = _xapian.delete_DatabaseVersionError
DatabaseVersionError_swigregister = _xapian.DatabaseVersionError_swigregister DatabaseVersionError_swigregister(DatabaseVersionError)
[docs]class DocNotFoundError(RuntimeError): """ Indicates an attempt to access a document not present in the database. """ __swig_setmethods__ = {} for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, DocNotFoundError, name, value) __swig_getmethods__ = {} for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, DocNotFoundError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::DocNotFoundError::DocNotFoundError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.DocNotFoundError_swiginit(self, _xapian.new_DocNotFoundError(*args)) __swig_destroy__ = _xapian.delete_DocNotFoundError
DocNotFoundError_swigregister = _xapian.DocNotFoundError_swigregister DocNotFoundError_swigregister(DocNotFoundError)
[docs]class FeatureUnavailableError(RuntimeError): """ Indicates an attempt to use a feature which is unavailable. Typically a feature is unavailable because it wasn't compiled in, or because it requires other software or facilities which aren't available. """ __swig_setmethods__ = {} for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, FeatureUnavailableError, name, value) __swig_getmethods__ = {} for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, FeatureUnavailableError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::FeatureUnavailableError::FeatureUnavailableError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.FeatureUnavailableError_swiginit(self, _xapian.new_FeatureUnavailableError(*args)) __swig_destroy__ = _xapian.delete_FeatureUnavailableError
FeatureUnavailableError_swigregister = _xapian.FeatureUnavailableError_swigregister FeatureUnavailableError_swigregister(FeatureUnavailableError)
[docs]class InternalError(RuntimeError): """ InternalError indicates a runtime problem of some sort. """ __swig_setmethods__ = {} for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, InternalError, name, value) __swig_getmethods__ = {} for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, InternalError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::InternalError::InternalError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.InternalError_swiginit(self, _xapian.new_InternalError(*args)) __swig_destroy__ = _xapian.delete_InternalError
InternalError_swigregister = _xapian.InternalError_swigregister InternalError_swigregister(InternalError)
[docs]class NetworkError(RuntimeError): """ Indicates a problem communicating with a remote database. """ __swig_setmethods__ = {} for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, NetworkError, name, value) __swig_getmethods__ = {} for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, NetworkError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::NetworkError::NetworkError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.NetworkError_swiginit(self, _xapian.new_NetworkError(*args)) __swig_destroy__ = _xapian.delete_NetworkError
NetworkError_swigregister = _xapian.NetworkError_swigregister NetworkError_swigregister(NetworkError)
[docs]class NetworkTimeoutError(NetworkError): """ Indicates a timeout expired while communicating with a remote database. """ __swig_setmethods__ = {} for _s in [NetworkError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, NetworkTimeoutError, name, value) __swig_getmethods__ = {} for _s in [NetworkError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, NetworkTimeoutError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::NetworkTimeoutError::NetworkTimeoutError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.NetworkTimeoutError_swiginit(self, _xapian.new_NetworkTimeoutError(*args)) __swig_destroy__ = _xapian.delete_NetworkTimeoutError
NetworkTimeoutError_swigregister = _xapian.NetworkTimeoutError_swigregister NetworkTimeoutError_swigregister(NetworkTimeoutError)
[docs]class QueryParserError(RuntimeError): """ Indicates a query string can't be parsed. """ __swig_setmethods__ = {} for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, QueryParserError, name, value) __swig_getmethods__ = {} for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, QueryParserError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::QueryParserError::QueryParserError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.QueryParserError_swiginit(self, _xapian.new_QueryParserError(*args)) __swig_destroy__ = _xapian.delete_QueryParserError
QueryParserError_swigregister = _xapian.QueryParserError_swigregister QueryParserError_swigregister(QueryParserError)
[docs]class SerialisationError(RuntimeError): """ Indicates an error in the std::string serialisation of an object. """ __swig_setmethods__ = {} for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, SerialisationError, name, value) __swig_getmethods__ = {} for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, SerialisationError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::SerialisationError::SerialisationError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.SerialisationError_swiginit(self, _xapian.new_SerialisationError(*args)) __swig_destroy__ = _xapian.delete_SerialisationError
SerialisationError_swigregister = _xapian.SerialisationError_swigregister SerialisationError_swigregister(SerialisationError)
[docs]class RangeError(RuntimeError): """ RangeError indicates an attempt to access outside the bounds of a container. """ __swig_setmethods__ = {} for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, RangeError, name, value) __swig_getmethods__ = {} for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, RangeError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::RangeError::RangeError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.RangeError_swiginit(self, _xapian.new_RangeError(*args)) __swig_destroy__ = _xapian.delete_RangeError
RangeError_swigregister = _xapian.RangeError_swigregister RangeError_swigregister(RangeError)
[docs]class WildcardError(RuntimeError): """ WildcardError indicates an error expanding a wildcarded query. """ __swig_setmethods__ = {} for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, WildcardError, name, value) __swig_getmethods__ = {} for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, WildcardError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::WildcardError::WildcardError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.WildcardError_swiginit(self, _xapian.new_WildcardError(*args)) __swig_destroy__ = _xapian.delete_WildcardError
WildcardError_swigregister = _xapian.WildcardError_swigregister WildcardError_swigregister(WildcardError)
[docs]class DatabaseNotFoundError(DatabaseOpeningError): """ Indicates an attempt to access a database not present. """ __swig_setmethods__ = {} for _s in [DatabaseOpeningError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseNotFoundError, name, value) __swig_getmethods__ = {} for _s in [DatabaseOpeningError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, DatabaseNotFoundError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::DatabaseNotFoundError::DatabaseNotFoundError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.DatabaseNotFoundError_swiginit(self, _xapian.new_DatabaseNotFoundError(*args)) __swig_destroy__ = _xapian.delete_DatabaseNotFoundError
DatabaseNotFoundError_swigregister = _xapian.DatabaseNotFoundError_swigregister DatabaseNotFoundError_swigregister(DatabaseNotFoundError)
[docs]class DatabaseClosedError(DatabaseError): """ Indicates an attempt to access a closed database. """ __swig_setmethods__ = {} for _s in [DatabaseError]: __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseClosedError, name, value) __swig_getmethods__ = {} for _s in [DatabaseError]: __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) __getattr__ = lambda self, name: _swig_getattr(self, DatabaseClosedError, name) __repr__ = _swig_repr def __init__(self, *args): """ Construct from message and errno value. Xapian::DatabaseClosedError::DatabaseClosedError(const std::string &msg_, int errno_) Parameters: ----------- msg_: Message giving details of the error, intended for human consumption. errno_: Optional errno value associated with this error. """ _xapian.DatabaseClosedError_swiginit(self, _xapian.new_DatabaseClosedError(*args)) __swig_destroy__ = _xapian.delete_DatabaseClosedError
DatabaseClosedError_swigregister = _xapian.DatabaseClosedError_swigregister DatabaseClosedError_swigregister(DatabaseClosedError) def version_string(): return _xapian.version_string() version_string = _xapian.version_string def major_version(): return _xapian.major_version() major_version = _xapian.major_version def minor_version(): return _xapian.minor_version() minor_version = _xapian.minor_version def revision(): return _xapian.revision() revision = _xapian.revision BAD_VALUENO = _xapian.BAD_VALUENO DB_CREATE = _xapian.DB_CREATE DB_CREATE_OR_OPEN = _xapian.DB_CREATE_OR_OPEN DB_CREATE_OR_OVERWRITE = _xapian.DB_CREATE_OR_OVERWRITE DB_OPEN = _xapian.DB_OPEN DB_NO_SYNC = _xapian.DB_NO_SYNC DB_FULL_SYNC = _xapian.DB_FULL_SYNC DB_DANGEROUS = _xapian.DB_DANGEROUS DB_NO_TERMLIST = _xapian.DB_NO_TERMLIST DB_BACKEND_CHERT = _xapian.DB_BACKEND_CHERT DB_BACKEND_GLASS = _xapian.DB_BACKEND_GLASS DB_BACKEND_INMEMORY = _xapian.DB_BACKEND_INMEMORY DB_BACKEND_STUB = _xapian.DB_BACKEND_STUB DB_RETRY_LOCK = _xapian.DB_RETRY_LOCK DBCHECK_SHORT_TREE = _xapian.DBCHECK_SHORT_TREE DBCHECK_FULL_TREE = _xapian.DBCHECK_FULL_TREE DBCHECK_SHOW_FREELIST = _xapian.DBCHECK_SHOW_FREELIST DBCHECK_SHOW_STATS = _xapian.DBCHECK_SHOW_STATS DBCHECK_FIX = _xapian.DBCHECK_FIX DBCOMPACT_MULTIPASS = _xapian.DBCOMPACT_MULTIPASS DBCOMPACT_NO_RENUMBER = _xapian.DBCOMPACT_NO_RENUMBER DBCOMPACT_SINGLE_FILE = _xapian.DBCOMPACT_SINGLE_FILE DOC_ASSUME_VALID = _xapian.DOC_ASSUME_VALID class _PositionIterator(object): """ Class for iterating over term positions. """ thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self): """ Default constructor. Xapian::PositionIterator::PositionIterator() Creates an uninitialised iterator, which can't be used before being assigned to, but is sometimes syntactically convenient. """ _xapian._PositionIterator_swiginit(self, _xapian.new__PositionIterator()) __swig_destroy__ = _xapian.delete__PositionIterator def skip_to(self, termpos): """ Advance the iterator to term position termpos. void Xapian::PositionIterator::skip_to(Xapian::termpos termpos) Parameters: ----------- termpos: The position to advance to. If this position isn't in the stream being iterated, then the iterator is moved to the next term position after it which is. """ return _xapian._PositionIterator_skip_to(self, termpos) def __str__(self): """ Return a string describing this object. std::string Xapian::PositionIterator::get_description() const """ return _xapian._PositionIterator___str__(self) _PositionIterator.skip_to = new_instancemethod(_xapian._PositionIterator_skip_to, None, _PositionIterator) _PositionIterator.__str__ = new_instancemethod(_xapian._PositionIterator___str__, None, _PositionIterator) _PositionIterator.__eq__ = new_instancemethod(_xapian._PositionIterator___eq__, None, _PositionIterator) _PositionIterator.__ne__ = new_instancemethod(_xapian._PositionIterator___ne__, None, _PositionIterator) _PositionIterator.equals = new_instancemethod(_xapian._PositionIterator_equals, None, _PositionIterator) _PositionIterator.get_termpos = new_instancemethod(_xapian._PositionIterator_get_termpos, None, _PositionIterator) _PositionIterator.next = new_instancemethod(_xapian._PositionIterator_next, None, _PositionIterator) _PositionIterator_swigregister = _xapian._PositionIterator_swigregister _PositionIterator_swigregister(_PositionIterator) class _PostingIterator(object): """ Class for iterating over a list of terms. """ thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self): """ Default constructor. Xapian::PostingIterator::PostingIterator() Creates an uninitialised iterator, which can't be used before being assigned to, but is sometimes syntactically convenient. """ _xapian._PostingIterator_swiginit(self, _xapian.new__PostingIterator()) __swig_destroy__ = _xapian.delete__PostingIterator def get_wdf(self): """ Return the wdf for the document at the current position. Xapian::termcount Xapian::PostingIterator::get_wdf() const """ return _xapian._PostingIterator_get_wdf(self) def get_doclength(self): """ Return the length of the document at the current position. Xapian::termcount Xapian::PostingIterator::get_doclength() const """ return _xapian._PostingIterator_get_doclength(self) def get_unique_terms(self): """ Return the number of unique terms in the current document. Xapian::termcount Xapian::PostingIterator::get_unique_terms() const """ return _xapian._PostingIterator_get_unique_terms(self) def _positionlist_begin(self): """ Return a PositionIterator for the current document. PositionIterator Xapian::PostingIterator::positionlist_begin() const """ return _xapian._PostingIterator__positionlist_begin(self) def _positionlist_end(self): """ Return an end PositionIterator for the current document. PositionIterator Xapian::PostingIterator::positionlist_end() const """ return _xapian._PostingIterator__positionlist_end(self) def skip_to(self, did): """ Advance the iterator to document did. void Xapian::PostingIterator::skip_to(Xapian::docid did) Parameters: ----------- did: The document id to advance to. If this document id isn't in the stream being iterated, then the iterator is moved to the next document id after it which is. """ return _xapian._PostingIterator_skip_to(self, did) def __str__(self): """ Return a string describing this object. std::string Xapian::PostingIterator::get_description() const """ return _xapian._PostingIterator___str__(self) _PostingIterator.get_wdf = new_instancemethod(_xapian._PostingIterator_get_wdf, None, _PostingIterator) _PostingIterator.get_doclength = new_instancemethod(_xapian._PostingIterator_get_doclength, None, _PostingIterator) _PostingIterator.get_unique_terms = new_instancemethod(_xapian._PostingIterator_get_unique_terms, None, _PostingIterator) _PostingIterator._positionlist_begin = new_instancemethod(_xapian._PostingIterator__positionlist_begin, None, _PostingIterator) _PostingIterator._positionlist_end = new_instancemethod(_xapian._PostingIterator__positionlist_end, None, _PostingIterator) _PostingIterator.skip_to = new_instancemethod(_xapian._PostingIterator_skip_to, None, _PostingIterator) _PostingIterator.__str__ = new_instancemethod(_xapian._PostingIterator___str__, None, _PostingIterator) _PostingIterator.__eq__ = new_instancemethod(_xapian._PostingIterator___eq__, None, _PostingIterator) _PostingIterator.__ne__ = new_instancemethod(_xapian._PostingIterator___ne__, None, _PostingIterator) _PostingIterator.equals = new_instancemethod(_xapian._PostingIterator_equals, None, _PostingIterator) _PostingIterator.get_docid = new_instancemethod(_xapian._PostingIterator_get_docid, None, _PostingIterator) _PostingIterator.next = new_instancemethod(_xapian._PostingIterator_next, None, _PostingIterator) _PostingIterator_swigregister = _xapian._PostingIterator_swigregister _PostingIterator_swigregister(_PostingIterator) class _TermIterator(object): """ Class for iterating over a list of terms. """ thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self): """ Default constructor. Xapian::TermIterator::TermIterator() Creates an uninitialised iterator, which can't be used before being assigned to, but is sometimes syntactically convenient. """ _xapian._TermIterator_swiginit(self, _xapian.new__TermIterator()) __swig_destroy__ = _xapian.delete__TermIterator def get_wdf(self): """ Return the wdf for the term at the current position. Xapian::termcount Xapian::TermIterator::get_wdf() const """ return _xapian._TermIterator_get_wdf(self) def get_termfreq(self): """ Return the term frequency for the term at the current position. Xapian::doccount Xapian::TermIterator::get_termfreq() const """ return _xapian._TermIterator_get_termfreq(self) def positionlist_count(self): """ Return the length of the position list for the current position. Xapian::termcount Xapian::TermIterator::positionlist_count() const """ return _xapian._TermIterator_positionlist_count(self) def _positionlist_begin(self): """ Return a PositionIterator for the current term. PositionIterator Xapian::TermIterator::positionlist_begin() const """ return _xapian._TermIterator__positionlist_begin(self) def _positionlist_end(self): """ Return an end PositionIterator for the current term. PositionIterator Xapian::TermIterator::positionlist_end() const """ return _xapian._TermIterator__positionlist_end(self) def skip_to(self, term): """ Advance the iterator to term term. void Xapian::TermIterator::skip_to(const std::string &term) If the iteration is over an unsorted list of terms, then this method will throw Xapian::InvalidOperationError. Parameters: ----------- term: The term to advance to. If this term isn't in the stream being iterated, then the iterator is moved to the next term after it which is. """ return _xapian._TermIterator_skip_to(self, term) def __str__(self): """ Return a string describing this object. std::string Xapian::TermIterator::get_description() const """ return _xapian._TermIterator___str__(self) _TermIterator.get_wdf = new_instancemethod(_xapian._TermIterator_get_wdf, None, _TermIterator) _TermIterator.get_termfreq = new_instancemethod(_xapian._TermIterator_get_termfreq, None, _TermIterator) _TermIterator.positionlist_count = new_instancemethod(_xapian._TermIterator_positionlist_count, None, _TermIterator) _TermIterator._positionlist_begin = new_instancemethod(_xapian._TermIterator__positionlist_begin, None, _TermIterator) _TermIterator._positionlist_end = new_instancemethod(_xapian._TermIterator__positionlist_end, None, _TermIterator) _TermIterator.skip_to = new_instancemethod(_xapian._TermIterator_skip_to, None, _TermIterator) _TermIterator.__str__ = new_instancemethod(_xapian._TermIterator___str__, None, _TermIterator) _TermIterator.__eq__ = new_instancemethod(_xapian._TermIterator___eq__, None, _TermIterator) _TermIterator.__ne__ = new_instancemethod(_xapian._TermIterator___ne__, None, _TermIterator) _TermIterator.equals = new_instancemethod(_xapian._TermIterator_equals, None, _TermIterator) _TermIterator.get_term = new_instancemethod(_xapian._TermIterator_get_term, None, _TermIterator) _TermIterator.next = new_instancemethod(_xapian._TermIterator_next, None, _TermIterator) _TermIterator_swigregister = _xapian._TermIterator_swigregister _TermIterator_swigregister(_TermIterator) class _ValueIterator(object): """ Class for iterating over document values. """ thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self): """ Default constructor. Xapian::ValueIterator::ValueIterator() Creates an uninitialised iterator, which can't be used before being assigned to, but is sometimes syntactically convenient. """ _xapian._ValueIterator_swiginit(self, _xapian.new__ValueIterator()) __swig_destroy__ = _xapian.delete__ValueIterator def get_docid(self): """ Return the docid at the current position. Xapian::docid Xapian::ValueIterator::get_docid() const If we're iterating over values of a document, this method will throw Xapian::InvalidOperationError. """ return _xapian._ValueIterator_get_docid(self) def get_valueno(self): """ Return the value slot number for the current position. Xapian::valueno Xapian::ValueIterator::get_valueno() const If the iterator is over all values in a slot, this returns that slot's number. If the iterator is over the values in a particular document, it returns the number of each slot in turn. """ return _xapian._ValueIterator_get_valueno(self) def skip_to(self, docid_or_slot): """ Advance the iterator to document id or value slot docid_or_slot. void Xapian::ValueIterator::skip_to(Xapian::docid docid_or_slot) If this iterator is over values in a document, then this method advances the iterator to value slot docid_or_slot, or the first slot after it if there is no value in slot slot. If this iterator is over values in a particular slot, then this method advances the iterator to document id docid_or_slot, or the first document id after it if there is no value in the slot we're iterating over for document docid_or_slot. Note: The "two-faced" nature of this method is due to how C++ overloading works. Xapian::docid and Xapian::valueno are both typedefs for the same unsigned integer type, so overloading can't distinguish them. Parameters: ----------- docid_or_slot: The docid/slot to advance to. """ return _xapian._ValueIterator_skip_to(self, docid_or_slot) def check(self, docid): """ Check if the specified docid occurs. bool Xapian::ValueIterator::check(Xapian::docid docid) The caller is required to ensure that the specified document id did actually exists in the database. This method acts like skip_to() if that can be done at little extra cost, in which case it then returns true. This is how chert and glass databases behave because they store values in streams which allow for an efficient implementation of skip_to(). Otherwise it simply checks if a particular docid is present. If it is, it returns true. If it isn't, it returns false, and leaves the position unspecified (and hence the result of calling methods which depend on the current position, such as get_docid(), are also unspecified). In this state, next() will advance to the first matching position after document did, and skip_to() will act as it would if the position was the first matching position after document did. Currently the inmemory and remote backends behave in the latter way because they don't support streamed values and so skip_to() must check each document it skips over which is significantly slower. Parameters: ----------- docid: The document id to check. """ return _xapian._ValueIterator_check(self, docid) def __str__(self): """ Return a string describing this object. std::string Xapian::ValueIterator::get_description() const """ return _xapian._ValueIterator___str__(self) _ValueIterator.get_docid = new_instancemethod(_xapian._ValueIterator_get_docid, None, _ValueIterator) _ValueIterator.get_valueno = new_instancemethod(_xapian._ValueIterator_get_valueno, None, _ValueIterator) _ValueIterator.skip_to = new_instancemethod(_xapian._ValueIterator_skip_to, None, _ValueIterator) _ValueIterator.check = new_instancemethod(_xapian._ValueIterator_check, None, _ValueIterator) _ValueIterator.__str__ = new_instancemethod(_xapian._ValueIterator___str__, None, _ValueIterator) _ValueIterator.__eq__ = new_instancemethod(_xapian._ValueIterator___eq__, None, _ValueIterator) _ValueIterator.__ne__ = new_instancemethod(_xapian._ValueIterator___ne__, None, _ValueIterator) _ValueIterator.equals = new_instancemethod(_xapian._ValueIterator_equals, None, _ValueIterator) _ValueIterator.get_value = new_instancemethod(_xapian._ValueIterator_get_value, None, _ValueIterator) _ValueIterator.next = new_instancemethod(_xapian._ValueIterator_next, None, _ValueIterator) _ValueIterator_swigregister = _xapian._ValueIterator_swigregister _ValueIterator_swigregister(_ValueIterator)
[docs]class Document(object): """ A handle representing a document in a Xapian database. The Document class fetches information from the database lazily. Usually this behaviour isn't visible to users (except for the speed benefits), but if the document in the database is modified or deleted, then preexisting Document objects may return the old or new versions of data (or throw Xapian::DocNotFoundError in the case of deletion). Since Database objects work on a snapshot of the database's state, the situation above can only happen with a WritableDatabase object, or if you call Database::reopen() on a Database object. We recommend you avoid designs where this behaviour is an issue, but if you need a way to make a non-lazy version of a Document object, you can do this like so:doc = Xapian::Document::unserialise(doc.serialise()); """ thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self): """ Make a new empty Document. Xapian::Document::Document() """ _xapian.Document_swiginit(self, _xapian.new_Document()) __swig_destroy__ = _xapian.delete_Document def get_value(self, slot): """ Get value by number. std::string Xapian::Document::get_value(Xapian::valueno slot) const Returns an empty string if no value with the given number is present in the document. Parameters: ----------- slot: The number of the value. """ return _xapian.Document_get_value(self, slot) def add_value(self, slot, value): """ Add a new value. void Xapian::Document::add_value(Xapian::valueno slot, const std::string &value) The new value will replace any existing value with the same number (or if the new value is empty, it will remove any existing value with the same number). Parameters: ----------- slot: The value slot to add the value in. value: The value to set. """ return _xapian.Document_add_value(self, slot, value) def remove_value(self, slot): """ Remove any value with the given number. void Xapian::Document::remove_value(Xapian::valueno slot) """ return _xapian.Document_remove_value(self, slot) def clear_values(self): """ Remove all values associated with the document. void Xapian::Document::clear_values() """ return _xapian.Document_clear_values(self) def get_data(self): """ Get data stored in the document. std::string Xapian::Document::get_data() const This is potentially a relatively expensive operation, and shouldn't normally be used during the match (e.g. in a PostingSource or match decider functor. Put data for use by match deciders in a value instead. """ return _xapian.Document_get_data(self) def set_data(self, data): """ Set data stored in the document. void Xapian::Document::set_data(const std::string &data) Xapian treats the data as an opaque blob. It may try to compress it, but other than that it will just store it and return it when requested. Parameters: ----------- data: The data to store. """ return _xapian.Document_set_data(self, data) def add_posting(self, tname, tpos, wdfinc=1): """ Add an occurrence of a term at a particular position. void Xapian::Document::add_posting(const std::string &tname, Xapian::termpos tpos, Xapian::termcount wdfinc=1) Multiple occurrences of the term at the same position are represented only once in the positional information, but do increase the wdf. If the term is not already in the document, it will be added to it. Parameters: ----------- tname: The name of the term. tpos: The position of the term. wdfinc: The increment that will be applied to the wdf for this term. """ return _xapian.Document_add_posting(self, tname, tpos, wdfinc) def add_term(self, tname, wdfinc=1): """ Add a term to the document, without positional information. void Xapian::Document::add_term(const std::string &tname, Xapian::termcount wdfinc=1) Any existing positional information for the term will be left unmodified. Parameters: ----------- tname: The name of the term. wdfinc: The increment that will be applied to the wdf for this term (default: 1). """ return _xapian.Document_add_term(self, tname, wdfinc) def add_boolean_term(self, term): """ Add a boolean filter term to the document. void Xapian::Document::add_boolean_term(const std::string &term) This method adds term to the document with wdf of 0 - this is generally what you want for a term used for boolean filtering as the wdf of such terms is ignored, and it doesn't make sense for them to contribute to the document's length. If the specified term already indexes this document, this method has no effect. It is exactly the same as add_term(term, 0). This method was added in Xapian 1.0.18. Parameters: ----------- term: The term to add. """ return _xapian.Document_add_boolean_term(self, term) def remove_posting(self, tname, tpos, wdfdec=1): """ Remove a posting of a term from the document. void Xapian::Document::remove_posting(const std::string &tname, Xapian::termpos tpos, Xapian::termcount wdfdec=1) Note that the term will still index the document even if all occurrences are removed. To remove a term from a document completely, use remove_term(). Parameters: ----------- tname: The name of the term. tpos: The position of the term. wdfdec: The decrement that will be applied to the wdf when removing this posting. The wdf will not go below the value of 0. Parameters: ----------- Xapian::InvalidArgumentError: will be thrown if the term is not at the position specified in the position list for this term in this document. Xapian::InvalidArgumentError: will be thrown if the term is not in the document """ return _xapian.Document_remove_posting(self, tname, tpos, wdfdec) def remove_postings(self, term, term_pos_first, term_pos_last, wdf_dec=1): """ Remove a range of postings for a term. Xapian::termpos Xapian::Document::remove_postings(const std::string &term, Xapian::termpos term_pos_first, Xapian::termpos term_pos_last, Xapian::termcount wdf_dec=1) Any instances of the term at positions >= term_pos_first and <= term_pos_last will be removed, and the wdf reduced by wdf_dec for each instance removed (the wdf will not ever go below zero though). It's OK if the term doesn't occur in the range of positions specified (unlike remove_posting()). And if term_pos_first > term_pos_last, this method does nothing. The number of postings removed. Parameters: ----------- Xapian::InvalidArgumentError: will be thrown if the term is not in the document """ return _xapian.Document_remove_postings(self, term, term_pos_first, term_pos_last, wdf_dec) def remove_term(self, tname): """ Remove a term and all postings associated with it. void Xapian::Document::remove_term(const std::string &tname) Parameters: ----------- tname: The name of the term. Parameters: ----------- Xapian::InvalidArgumentError: will be thrown if the term is not in the document """ return _xapian.Document_remove_term(self, tname) def clear_terms(self): """ Remove all terms (and postings) from the document. void Xapian::Document::clear_terms() """ return _xapian.Document_clear_terms(self) def termlist_count(self): """ The length of the termlist - i.e. Xapian::termcount Xapian::Document::termlist_count() const the number of different terms which index this document. """ return _xapian.Document_termlist_count(self) def _termlist_begin(self): """ Iterator for the terms in this document. TermIterator Xapian::Document::termlist_begin() const """ return _xapian.Document__termlist_begin(self) def _termlist_end(self): """ Equivalent end iterator for termlist_begin(). TermIterator Xapian::Document::termlist_end() const """ return _xapian.Document__termlist_end(self) def values_count(self): """ Count the values in this document. Xapian::termcount Xapian::Document::values_count() const """ return _xapian.Document_values_count(self) def _values_begin(self): """ Iterator for the values in this document. ValueIterator Xapian::Document::values_begin() const """ return _xapian.Document__values_begin(self) def _values_end(self): """ Equivalent end iterator for values_begin(). ValueIterator Xapian::Document::values_end() const """ return _xapian.Document__values_end(self) def get_docid(self): """ Get the document id which is associated with this document (if any). docid Xapian::Document::get_docid() const NB If multiple databases are being searched together, then this will be the document id in the individual database, not the merged database! If this document came from a database, return the document id in that database. Otherwise, return 0 (in Xapian 1.0.22/1.2.4 or later; prior to this the returned value was uninitialised). """ return _xapian.Document_get_docid(self) def serialise(self): """ Serialise document into a string. std::string Xapian::Document::serialise() const The document representation may change between Xapian releases: even between minor versions. However, it is guaranteed not to change if the remote database protocol has not changed between releases. """ return _xapian.Document_serialise(self) unserialise = staticmethod(_xapian.Document_unserialise) def __str__(self): """ Return a string describing this object. std::string Xapian::Document::get_description() const """ return _xapian.Document___str__(self)
Document.get_value = new_instancemethod(_xapian.Document_get_value, None, Document) Document.add_value = new_instancemethod(_xapian.Document_add_value, None, Document) Document.remove_value = new_instancemethod(_xapian.Document_remove_value, None, Document) Document.clear_values = new_instancemethod(_xapian.Document_clear_values, None, Document) Document.get_data = new_instancemethod(_xapian.Document_get_data, None, Document) Document.set_data = new_instancemethod(_xapian.Document_set_data, None, Document) Document.add_posting = new_instancemethod(_xapian.Document_add_posting, None, Document) Document.add_term = new_instancemethod(_xapian.Document_add_term, None, Document) Document.add_boolean_term = new_instancemethod(_xapian.Document_add_boolean_term, None, Document) Document.remove_posting = new_instancemethod(_xapian.Document_remove_posting, None, Document) Document.remove_postings = new_instancemethod(_xapian.Document_remove_postings, None, Document) Document.remove_term = new_instancemethod(_xapian.Document_remove_term, None, Document) Document.clear_terms = new_instancemethod(_xapian.Document_clear_terms, None, Document) Document.termlist_count = new_instancemethod(_xapian.Document_termlist_count, None, Document) Document._termlist_begin = new_instancemethod(_xapian.Document__termlist_begin, None, Document) Document._termlist_end = new_instancemethod(_xapian.Document__termlist_end, None, Document) Document.values_count = new_instancemethod(_xapian.Document_values_count, None, Document) Document._values_begin = new_instancemethod(_xapian.Document__values_begin, None, Document) Document._values_end = new_instancemethod(_xapian.Document__values_end, None, Document) Document.get_docid = new_instancemethod(_xapian.Document_get_docid, None, Document) Document.serialise = new_instancemethod(_xapian.Document_serialise, None, Document) Document.__str__ = new_instancemethod(_xapian.Document___str__, None, Document) Document_swigregister = _xapian.Document_swigregister Document_swigregister(Document) def Document_unserialise(serialised): return _xapian.Document_unserialise(serialised) Document_unserialise = _xapian.Document_unserialise
[docs]class Registry(object): """ Registry for user subclasses. This class provides a way for the remote server to look up user subclasses when unserialising. """ thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self): """ Default constructor. Xapian::Registry::Registry() The registry will contain all standard subclasses of user-subclassable classes. """ _xapian.Registry_swiginit(self, _xapian.new_Registry()) __swig_destroy__ = _xapian.delete_Registry def register_weighting_scheme(self, wt): """ Register a weighting scheme. void Xapian::Registry::register_weighting_scheme(const Xapian::Weight &wt) Parameters: ----------- wt: The weighting scheme to register. """ return _xapian.Registry_register_weighting_scheme(self, wt) def get_weighting_scheme(self, name): """ Get the weighting scheme given a name. const Xapian::Weight* Xapian::Registry::get_weighting_scheme(const std::string &name) const Parameters: ----------- name: The name of the weighting scheme to find. An object with the requested name, or NULL if the weighting scheme could not be found. The returned object is owned by the registry and so must not be deleted by the caller. """ return _xapian.Registry_get_weighting_scheme(self, name) def register_posting_source(self, source): """ Register a user-defined posting source class. void Xapian::Registry::register_posting_source(const Xapian::PostingSource &source) Parameters: ----------- source: The posting source to register. """ return _xapian.Registry_register_posting_source(self, source) def get_posting_source(self, name): """ Get a posting source given a name. const Xapian::PostingSource* Xapian::Registry::get_posting_source(const std::string &name) const Parameters: ----------- name: The name of the posting source to find. An object with the requested name, or NULL if the posting source could not be found. The returned object is owned by the registry and so must not be deleted by the caller. """ return _xapian.Registry_get_posting_source(self, name) def register_match_spy(self, spy): """ Register a user-defined match spy class. void Xapian::Registry::register_match_spy(const Xapian::MatchSpy &spy) Parameters: ----------- spy: The match spy to register. """ return _xapian.Registry_register_match_spy(self, spy) def get_match_spy(self, name): """ Get a match spy given a name. const Xapian::MatchSpy* Xapian::Registry::get_match_spy(const std::string &name) const Parameters: ----------- name: The name of the match spy to find. An object with the requested name, or NULL if the match spy could not be found. The returned object is owned by the registry and so must not be deleted by the caller. """ return _xapian.Registry_get_match_spy(self, name) def register_lat_long_metric(self, metric): """ Register a user-defined lat-long metric class. void Xapian::Registry::register_lat_long_metric(const Xapian::LatLongMetric &metric) """ return _xapian.Registry_register_lat_long_metric(self, metric) def get_lat_long_metric(self, name): """ Get a lat-long metric given a name. const Xapian::LatLongMetric* Xapian::Registry::get_lat_long_metric(const std::string &name) const The returned metric is owned by the registry object. Returns NULL if the metric could not be found. """ return _xapian.Registry_get_lat_long_metric(self, name)
Registry.register_weighting_scheme = new_instancemethod(_xapian.Registry_register_weighting_scheme, None, Registry) Registry.get_weighting_scheme = new_instancemethod(_xapian.Registry_get_weighting_scheme, None, Registry) Registry.register_posting_source = new_instancemethod(_xapian.Registry_register_posting_source, None, Registry) Registry.get_posting_source = new_instancemethod(_xapian.Registry_get_posting_source, None, Registry) Registry.register_match_spy = new_instancemethod(_xapian.Registry_register_match_spy, None, Registry) Registry.get_match_spy = new_instancemethod(_xapian.Registry_get_match_spy, None, Registry) Registry.register_lat_long_metric = new_instancemethod(_xapian.Registry_register_lat_long_metric, None, Registry) Registry.get_lat_long_metric = new_instancemethod(_xapian.Registry_get_lat_long_metric, None, Registry) Registry_swigregister = _xapian.Registry_swigregister Registry_swigregister(Registry)
[docs]class Query(object): """ Class representing a query. """ thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr OP_AND = _xapian.Query_OP_AND OP_OR = _xapian.Query_OP_OR OP_AND_NOT = _xapian.Query_OP_AND_NOT OP_XOR = _xapian.Query_OP_XOR OP_AND_MAYBE = _xapian.Query_OP_AND_MAYBE OP_FILTER = _xapian.Query_OP_FILTER OP_NEAR = _xapian.Query_OP_NEAR OP_PHRASE = _xapian.Query_OP_PHRASE OP_VALUE_RANGE = _xapian.Query_OP_VALUE_RANGE OP_SCALE_WEIGHT = _xapian.Query_OP_SCALE_WEIGHT OP_ELITE_SET = _xapian.Query_OP_ELITE_SET OP_VALUE_GE = _xapian.Query_OP_VALUE_GE OP_VALUE_LE = _xapian.Query_OP_VALUE_LE OP_SYNONYM = _xapian.Query_OP_SYNONYM OP_MAX = _xapian.Query_OP_MAX OP_WILDCARD = _xapian.Query_OP_WILDCARD OP_INVALID = _xapian.Query_OP_INVALID WILDCARD_LIMIT_ERROR = _xapian.Query_WILDCARD_LIMIT_ERROR WILDCARD_LIMIT_FIRST = _xapian.Query_WILDCARD_LIMIT_FIRST WILDCARD_LIMIT_MOST_FREQUENT = _xapian.Query_WILDCARD_LIMIT_MOST_FREQUENT __swig_destroy__ = _xapian.delete_Query def _get_terms_begin(self): """ Begin iterator for terms in the query object. const TermIterator Xapian::Query::get_terms_begin() const The iterator returns terms in ascending query position order, and will return the same term in each unique position it occurs in. If you want the terms in sorted order and without duplicates, see get_unique_terms_begin(). """ return _xapian.Query__get_terms_begin(self) def _get_terms_end(self): """ End iterator for terms in the query object. const TermIterator Xapian::Query::get_terms_end() const """ return _xapian.Query__get_terms_end(self) def get_unique_terms_begin(self): """ Begin iterator for unique terms in the query object. const TermIterator Xapian::Query::get_unique_terms_begin() const Terms are sorted and terms with the same name removed from the list. If you want the terms in ascending query position order, see get_terms_begin(). """ return _xapian.Query_get_unique_terms_begin(self) def get_length(self): """ Return the length of this query object. Xapian::termcount Xapian::Query::get_length() const """ return _xapian.Query_get_length(self) def empty(self): """ Check if this query is Xapian::Query::MatchNothing. bool Xapian::Query::empty() const """ return _xapian.Query_empty(self) def serialise(self): """ Serialise this object into a string. std::string Xapian::Query::serialise() const """ return _xapian.Query_serialise(self) unserialise = staticmethod(_xapian.Query_unserialise) def get_type(self): """ Get the type of the top level of the query. op Xapian::Query::get_type() const """ return _xapian.Query_get_type(self) def get_num_subqueries(self): """ Get the number of subqueries of the top level query. size_t Xapian::Query::get_num_subqueries() const """ return _xapian.Query_get_num_subqueries(self) def get_subquery(self, n): """ Read a top level subquery. const Query Xapian::Query::get_subquery(size_t n) const Parameters: ----------- n: Return the n-th subquery (starting from 0) - only valid when 0 <= n < get_num_subqueries(). """ return _xapian.Query_get_subquery(self, n) def __str__(self): """ Return a string describing this object. std::string Xapian::Query::get_description() const """ return _xapian.Query___str__(self) def __init__(self, *args): """ Construct with just an operator. Xapian::Query::Query(Query::op op_) Parameters: ----------- op_: The operator to use - currently only OP_INVALID is useful. """ _xapian.Query_swiginit(self, _xapian.new_Query(*args))
Query._get_terms_begin = new_instancemethod(_xapian.Query__get_terms_begin, None, Query) Query._get_terms_end = new_instancemethod(_xapian.Query__get_terms_end, None, Query) Query.get_unique_terms_begin = new_instancemethod(_xapian.Query_get_unique_terms_begin, None, Query) Query.get_length = new_instancemethod(_xapian.Query_get_length, None, Query) Query.empty = new_instancemethod(_xapian.Query_empty, None, Query) Query.serialise = new_instancemethod(_xapian.Query_serialise, None, Query) Query.get_type = new_instancemethod(_xapian.Query_get_type, None, Query) Query.get_num_subqueries = new_instancemethod(_xapian.Query_get_num_subqueries, None, Query) Query.get_subquery = new_instancemethod(_xapian.Query_get_subquery, None, Query) Query.__str__ = new_instancemethod(_xapian.Query___str__, None, Query) Query_swigregister = _xapian.Query_swigregister Query_swigregister(Query) def Query_unserialise(*args): return _xapian.Query_unserialise(*args) Query_unserialise = _xapian.Query_unserialise def __or__(a, b): return _xapian.__or__(a, b) __or__ = _xapian.__or__ def __xor__(a, b): return _xapian.__xor__(a, b) __xor__ = _xapian.__xor__ def __mul__(*args): return _xapian.__mul__(*args) __mul__ = _xapian.__mul__ def __truediv__(q, factor): return _xapian.__truediv__(q, factor) __truediv__ = _xapian.__truediv__ def __and__(*args): return _xapian.__and__(*args) __and__ = _xapian.__and__
[docs]class StemImplementation(object): """ Class representing a stemming algorithm implementation. """ thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self): """ Default constructor. Xapian::StemImplementation::StemImplementation() """ if self.__class__ == StemImplementation: _self = None else: _self = self _xapian.StemImplementation_swiginit(self, _xapian.new_StemImplementation(_self, )) __swig_destroy__ = _xapian.delete_StemImplementation def __str__(self): """ Return a string describing this object. virtual std::string Xapian::StemImplementation::get_description() const =0 """ return _xapian.StemImplementation___str__(self) def __disown__(self): self.this.disown() _xapian.disown_StemImplementation(self) return weakref_proxy(self)
StemImplementation.__call__ = new_instancemethod(_xapian.StemImplementation___call__, None, StemImplementation) StemImplementation.__str__ = new_instancemethod(_xapian.StemImplementation___str__, None, StemImplementation) StemImplementation_swigregister = _xapian.StemImplementation_swigregister StemImplementation_swigregister(StemImplementation)
[docs]class Stem(object): """ Class representing a stemming algorithm. """ thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self, *args): """ Construct a Xapian::Stem object with a user-provided stemming algorithm. Xapian::Stem::Stem(StemImplementation *p) You can subclass Xapian::StemImplementation to implement your own stemming algorithm (or to wrap a third-party algorithm) and then wrap your implementation in a Xapian::Stem object to pass to the Xapian API. Parameters: ----------- p: The user-subclassed StemImplementation object. This is reference counted, and so will be automatically deleted by the Xapian::Stem wrapper when no longer required. """ _xapian.Stem_swiginit(self, _xapian.new_Stem(*args)) __swig_destroy__ = _xapian.delete_Stem def __str__(self): """ Return a string describing this object. std::string Xapian::Stem::get_description() const """ return _xapian.Stem___str__(self) get_available_languages = staticmethod(_xapian.Stem_get_available_languages)
Stem.__call__ = new_instancemethod(_xapian.Stem___call__, None, Stem) Stem.__str__ = new_instancemethod(_xapian.Stem___str__, None, Stem) Stem_swigregister = _xapian.Stem_swigregister Stem_swigregister(Stem) def Stem_get_available_languages(): return _xapian.Stem_get_available_languages() Stem_get_available_languages = _xapian.Stem_get_available_languages
[docs]class TermGenerator(object): """ Parses a piece of text and generate terms. This module takes a piece of text and parses it to produce words which are then used to generate suitable terms for indexing. The terms generated are suitable for use with Query objects produced by the QueryParser class. """ thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self): """ Default constructor. Xapian::TermGenerator::TermGenerator() """ _xapian.TermGenerator_swiginit(self, _xapian.new_TermGenerator()) __swig_destroy__ = _xapian.delete_TermGenerator def set_stemmer(self, stemmer): """ Set the Xapian::Stem object to be used for generating stemmed terms. void Xapian::TermGenerator::set_stemmer(const Xapian::Stem &stemmer) """ return _xapian.TermGenerator_set_stemmer(self, stemmer)
[docs] def set_stopper(self, stop=None): """ Set the Xapian::Stopper object to be used for identifying stopwords. void Xapian::TermGenerator::set_stopper(const Xapian::Stopper *stop=NULL) Stemmed forms of stopwords aren't indexed, but unstemmed forms still are so that searches for phrases including stop words still work. Parameters: ----------- stop: The Stopper object to set (default NULL, which means no stopwords). """ return _xapian.TermGenerator_set_stopper(self, stop)
def set_document(self, doc): """ Set the current document. void Xapian::TermGenerator::set_document(const Xapian::Document &doc) """ return _xapian.TermGenerator_set_document(self, doc) def get_document(self): """ Get the current document. const Xapian::Document& Xapian::TermGenerator::get_document() const """ return _xapian.TermGenerator_get_document(self) def set_database(self, db): """ Set the database to index spelling data to. void Xapian::TermGenerator::set_database(const Xapian::WritableDatabase &db) """ return _xapian.TermGenerator_set_database(self, db) FLAG_SPELLING = _xapian.TermGenerator_FLAG_SPELLING FLAG_CJK_NGRAM = _xapian.TermGenerator_FLAG_CJK_NGRAM STEM_NONE = _xapian.TermGenerator_STEM_NONE STEM_SOME = _xapian.TermGenerator_STEM_SOME STEM_ALL = _xapian.TermGenerator_STEM_ALL STEM_ALL_Z = _xapian.TermGenerator_STEM_ALL_Z STEM_SOME_FULL_POS = _xapian.TermGenerator_STEM_SOME_FULL_POS STOP_NONE = _xapian.TermGenerator_STOP_NONE STOP_ALL = _xapian.TermGenerator_STOP_ALL STOP_STEMMED = _xapian.TermGenerator_STOP_STEMMED def set_flags(self, *args): """ Set flags. flags Xapian::TermGenerator::set_flags(flags toggle, flags mask=flags(0)) The new value of flags is: (flags & mask) ^ toggle To just set the flags, pass the new flags in toggle and the default value for mask. Parameters: ----------- toggle: Flags to XOR. mask: Flags to AND with first. The old flags setting. """ return _xapian.TermGenerator_set_flags(self, *args) def set_stemming_strategy(self, strategy): """ Set the stemming strategy. void Xapian::TermGenerator::set_stemming_strategy(stem_strategy strategy) This method controls how the stemming algorithm is applied. It was new in Xapian 1.3.1. Parameters: ----------- strategy: The strategy to use - possible values are: STEM_NONE: Don't perform any stemming - only unstemmed terms are generated. STEM_SOME: Generate both stemmed (with a "Z" prefix) and unstemmed terms. No positional information is stored for unstemmed terms. This is the default strategy. STEM_SOME_FULL_POS: Like STEM_SOME but positional information is stored for both stemmed and unstemmed terms. Added in Xapian 1.4.8. STEM_ALL: Generate only stemmed terms (but without a "Z" prefix). STEM_ALL_Z: Generate only stemmed terms (with a "Z" prefix). """ return _xapian.TermGenerator_set_stemming_strategy(self, strategy) def set_stopper_strategy(self, strategy): """ Set the stopper strategy. void Xapian::TermGenerator::set_stopper_strategy(stop_strategy strategy) The method controls how the stopper is used. It was added in Xapian 1.4.1. You need to also call set_stopper() for this to have any effect. Parameters: ----------- strategy: The strategy to use - possible values are: STOP_NONE: Don't use the stopper. STOP_ALL: If a word is identified as a stop word, skip it completely. STOP_STEMMED: If a word is identified as a stop word, index its unstemmed form but skip the stem. Unstemmed forms are indexed with positional information by default, so this allows searches for phrases containing stopwords to be supported. (This is the default mode). """ return _xapian.TermGenerator_set_stopper_strategy(self, strategy) def set_max_word_length(self, max_word_length): """ Set the maximum length word to index. void Xapian::TermGenerator::set_max_word_length(unsigned max_word_length) The limit is on the length of a word prior to stemming and prior to adding any term prefix. The backends mostly impose a limit on the length of terms (often of about 240 bytes), but it's generally useful to have a lower limit to help prevent the index being bloated by useless junk terms from trying to indexing things like binary data, uuencoded data, ASCII art, etc. This method was new in Xapian 1.3.1. Parameters: ----------- max_word_length: The maximum length word to index, in bytes in UTF-8 representation. Default is 64. """ return _xapian.TermGenerator_set_max_word_length(self, max_word_length) def index_text(self, *args): """ Index some text in a std::string. void Xapian::TermGenerator::index_text(const std::string &text, Xapian::termcount wdf_inc=1, const std::string &prefix=std::string()) Parameters: ----------- text: The text to index. wdf_inc: The wdf increment (default 1). prefix: The term prefix to use (default is no prefix). """ return _xapian.TermGenerator_index_text(self, *args) def index_text_without_positions(self, *args): """ Index some text in a std::string without positional information. void Xapian::TermGenerator::index_text_without_positions(const std::string &text, Xapian::termcount wdf_inc=1, const std::string &prefix=std::string()) Just like index_text, but no positional information is generated. This means that the database will be significantly smaller, but that phrase searching and NEAR won't be supported. Parameters: ----------- text: The text to index. wdf_inc: The wdf increment (default 1). prefix: The term prefix to use (default is no prefix). """ return _xapian.TermGenerator_index_text_without_positions(self, *args) def increase_termpos(self, delta=100): """ Increase the term position used by index_text. void Xapian::TermGenerator::increase_termpos(Xapian::termpos delta=100) This can be used between indexing text from different fields or other places to prevent phrase searches from spanning between them (e.g. between the title and body text, or between two chapters in a book). Parameters: ----------- delta: Amount to increase the term position by (default: 100). """ return _xapian.TermGenerator_increase_termpos(self, delta) def get_termpos(self): """ Get the current term position. Xapian::termpos Xapian::TermGenerator::get_termpos() const """ return _xapian.TermGenerator_get_termpos(self) def set_termpos(self, termpos): """ Set the current term position. void Xapian::TermGenerator::set_termpos(Xapian::termpos termpos) Parameters: ----------- termpos: The new term position to set. """ return _xapian.TermGenerator_set_termpos(self, termpos) def __str__(self): """ Return a string describing this object. std::string Xapian::TermGenerator::get_description() const """ return _xapian.TermGenerator___str__(self)
TermGenerator.set_stemmer = new_instancemethod(_xapian.TermGenerator_set_stemmer, None, TermGenerator) TermGenerator.set_stopper = new_instancemethod(_xapian.TermGenerator_set_stopper, None, TermGenerator) TermGenerator.set_document = new_instancemethod(_xapian.TermGenerator_set_document, None, TermGenerator) TermGenerator.get_document = new_instancemethod(_xapian.TermGenerator_get_document, None, TermGenerator) TermGenerator.set_database = new_instancemethod(_xapian.TermGenerator_set_database, None, TermGenerator) TermGenerator.set_flags = new_instancemethod(_xapian.TermGenerator_set_flags, None, TermGenerator) TermGenerator.set_stemming_strategy = new_instancemethod(_xapian.TermGenerator_set_stemming_strategy, None, TermGenerator) TermGenerator.set_stopper_strategy = new_instancemethod(_xapian.TermGenerator_set_stopper_strategy, None, TermGenerator) TermGenerator.set_max_word_length = new_instancemethod(_xapian.TermGenerator_set_max_word_length, None, TermGenerator) TermGenerator.index_text = new_instancemethod(_xapian.TermGenerator_index_text, None, TermGenerator) TermGenerator.index_text_without_positions = new_instancemethod(_xapian.TermGenerator_index_text_without_positions, None, TermGenerator) TermGenerator.increase_termpos = new_instancemethod(_xapian.TermGenerator_increase_termpos, None, TermGenerator) TermGenerator.get_termpos = new_instancemethod(_xapian.TermGenerator_get_termpos, None, TermGenerator) TermGenerator.set_termpos = new_instancemethod(_xapian.TermGenerator_set_termpos, None, TermGenerator) TermGenerator.__str__ = new_instancemethod(_xapian.TermGenerator___str__, None, TermGenerator) TermGenerator_swigregister = _xapian.TermGenerator_swigregister TermGenerator_swigregister(TermGenerator)
[docs]class MSet(object): """ Class representing a list of search results. """ thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self): """ Default constructor. Xapian::MSet::MSet() Creates an empty MSet, mostly useful as a placeholder. """ _xapian.MSet_swiginit(self, _xapian.new_MSet()) __swig_destroy__ = _xapian.delete_MSet def convert_to_percent(self, *args): """ Convert the weight of the current iterator position to a percentage. int Xapian::MSet::convert_to_percent(const MSetIterator &it) const The matching document with the highest weight will get 100% if it matches all the weighted query terms, and proportionally less if it only matches some, and other weights are scaled by the same factor. Documents with a non-zero score will always score at least 1%. Note that these generally aren't percentages of anything meaningful (unless you use a custom weighting formula where they are!) """ return _xapian.MSet_convert_to_percent(self, *args) def get_termfreq(self, term): """ Get the termfreq of a term. Xapian::doccount Xapian::MSet::get_termfreq(const std::string &term) const The number of documents term occurs in. """ return _xapian.MSet_get_termfreq(self, term) def get_termweight(self, term): """ Get the term weight of a term. double Xapian::MSet::get_termweight(const std::string &term) const The maximum weight that term could have contributed to a document. """ return _xapian.MSet_get_termweight(self, term) def get_firstitem(self): """ Rank of first item in this MSet. Xapian::doccount Xapian::MSet::get_firstitem() const This is the parameter first passed to Xapian::Enquire::get_mset(). """ return _xapian.MSet_get_firstitem(self) def get_matches_lower_bound(self): """ Lower bound on the total number of matching documents. Xapian::doccount Xapian::MSet::get_matches_lower_bound() const """ return _xapian.MSet_get_matches_lower_bound(self) def get_matches_estimated(self): """ Estimate of the total number of matching documents. Xapian::doccount Xapian::MSet::get_matches_estimated() const """ return _xapian.MSet_get_matches_estimated(self) def get_matches_upper_bound(self): """ Upper bound on the total number of matching documents. Xapian::doccount Xapian::MSet::get_matches_upper_bound() const """ return _xapian.MSet_get_matches_upper_bound(self) def get_uncollapsed_matches_lower_bound(self): """ Lower bound on the total number of matching documents before collapsing. Xapian::doccount Xapian::MSet::get_uncollapsed_matches_lower_bound() const Conceptually the same as get_matches_lower_bound() for the same query without any collapse part (though the actual value may differ). """ return _xapian.MSet_get_uncollapsed_matches_lower_bound(self) def get_uncollapsed_matches_estimated(self): """ Estimate of the total number of matching documents before collapsing. Xapian::doccount Xapian::MSet::get_uncollapsed_matches_estimated() const Conceptually the same as get_matches_estimated() for the same query without any collapse part (though the actual value may differ). """ return _xapian.MSet_get_uncollapsed_matches_estimated(self) def get_uncollapsed_matches_upper_bound(self): """ Upper bound on the total number of matching documents before collapsing. Xapian::doccount Xapian::MSet::get_uncollapsed_matches_upper_bound() const Conceptually the same as get_matches_upper_bound() for the same query without any collapse part (though the actual value may differ). """ return _xapian.MSet_get_uncollapsed_matches_upper_bound(self) def get_max_attained(self): """ The maximum weight attained by any document. double Xapian::MSet::get_max_attained() const """ return _xapian.MSet_get_max_attained(self) def get_max_possible(self): """ The maximum possible weight any document could achieve. double Xapian::MSet::get_max_possible() const """ return _xapian.MSet_get_max_possible(self) SNIPPET_BACKGROUND_MODEL = _xapian.MSet_SNIPPET_BACKGROUND_MODEL SNIPPET_EXHAUSTIVE = _xapian.MSet_SNIPPET_EXHAUSTIVE SNIPPET_EMPTY_WITHOUT_MATCH = _xapian.MSet_SNIPPET_EMPTY_WITHOUT_MATCH SNIPPET_CJK_NGRAM = _xapian.MSet_SNIPPET_CJK_NGRAM def snippet(self, *args): """ Generate a snippet. std::string Xapian::MSet::snippet(const std::string &text, size_t length=500, const Xapian::Stem &stemmer=Xapian::Stem(), unsigned flags=SNIPPET_BACKGROUND_MODEL|SNIPPET_EXHAUSTIVE, const std::string &hi_start="<b>", const std::string &hi_end="</b>", const std::string &omit="...") const This method selects a continuous run of words from text, based mainly on where the query matches (currently terms, exact phrases and wildcards are taken into account). If flag SNIPPET_BACKGROUND_MODEL is used (which it is by default) then the selection algorithm also considers the non-query terms in the text with the aim of showing a context which provides more useful information. The size of the text selected can be controlled by the length parameter, which specifies a number of bytes of text to aim to select. However slightly more text may be selected. Also the size of any escaping, highlighting or omission markers is not considered. The returned text is escaped to make it suitable for use in HTML (though beware that in upstream releases 1.4.5 and earlier this escaping was sometimes incomplete), and matches with the query will be highlighted using hi_start and hi_end. If the snippet seems to start or end mid-sentence, then omit is prepended or append (respectively) to indicate this. The same stemming algorithm which was used to build the query should be specified in stemmer. And flags contains flags controlling behaviour. Added in 1.3.5. """ return _xapian.MSet_snippet(self, *args) def fetch(self, *args): """ Prefetch hint the whole MSet. void Xapian::MSet::fetch() const For a remote database, this may start a pipelined fetch of the requested documents from the remote server. For a disk-based database, this may send prefetch hints to the operating system such that the disk blocks the requested documents are stored in are more likely to be in the cache when we come to actually read them. """ return _xapian.MSet_fetch(self, *args) def size(self): """ Return number of items in this MSet object. Xapian::doccount Xapian::MSet::size() const """ return _xapian.MSet_size(self) def empty(self): """ Return true if this MSet object is empty. bool Xapian::MSet::empty() const """ return _xapian.MSet_empty(self) def _begin(self): """ Return iterator pointing to the first item in this MSet. MSetIterator Xapian::MSet::begin() const """ return _xapian.MSet__begin(self) def _end(self): """ Return iterator pointing to just after the last item in this MSet. MSetIterator Xapian::MSet::end() const """ return _xapian.MSet__end(self) def back(self): """ Return iterator pointing to the last object in this MSet. MSetIterator Xapian::MSet::back() const """ return _xapian.MSet_back(self) def __str__(self): """ Return a string describing this object. std::string Xapian::MSet::get_description() const """ return _xapian.MSet___str__(self) items = property(_xapian.MSet_items_get) def _get_hit_internal(self, i): """ Get an item from the MSet. The supplied index is relative to the start of the MSet, not the absolute rank of the item. """ return _xapian.MSet__get_hit_internal(self, i)
MSet.convert_to_percent = new_instancemethod(_xapian.MSet_convert_to_percent, None, MSet) MSet.get_termfreq = new_instancemethod(_xapian.MSet_get_termfreq, None, MSet) MSet.get_termweight = new_instancemethod(_xapian.MSet_get_termweight, None, MSet) MSet.get_firstitem = new_instancemethod(_xapian.MSet_get_firstitem, None, MSet) MSet.get_matches_lower_bound = new_instancemethod(_xapian.MSet_get_matches_lower_bound, None, MSet) MSet.get_matches_estimated = new_instancemethod(_xapian.MSet_get_matches_estimated, None, MSet) MSet.get_matches_upper_bound = new_instancemethod(_xapian.MSet_get_matches_upper_bound, None, MSet) MSet.get_uncollapsed_matches_lower_bound = new_instancemethod(_xapian.MSet_get_uncollapsed_matches_lower_bound, None, MSet) MSet.get_uncollapsed_matches_estimated = new_instancemethod(_xapian.MSet_get_uncollapsed_matches_estimated, None, MSet) MSet.get_uncollapsed_matches_upper_bound = new_instancemethod(_xapian.MSet_get_uncollapsed_matches_upper_bound, None, MSet) MSet.get_max_attained = new_instancemethod(_xapian.MSet_get_max_attained, None, MSet) MSet.get_max_possible = new_instancemethod(_xapian.MSet_get_max_possible, None, MSet) MSet.snippet = new_instancemethod(_xapian.MSet_snippet, None, MSet) MSet.fetch = new_instancemethod(_xapian.MSet_fetch, None, MSet) MSet.size = new_instancemethod(_xapian.MSet_size, None, MSet) MSet.empty = new_instancemethod(_xapian.MSet_empty, None, MSet) MSet._begin = new_instancemethod(_xapian.MSet__begin, None, MSet) MSet._end = new_instancemethod(_xapian.MSet__end, None, MSet) MSet.back = new_instancemethod(_xapian.MSet_back, None, MSet) MSet.__str__ = new_instancemethod(_xapian.MSet___str__, None, MSet) MSet.__cmp__ = new_instancemethod(_xapian.MSet___cmp__, None, MSet) MSet.get_docid = new_instancemethod(_xapian.MSet_get_docid, None, MSet) MSet.get_document = new_instancemethod(_xapian.MSet_get_document, None, MSet) MSet._get_hit_internal = new_instancemethod(_xapian.MSet__get_hit_internal, None, MSet) MSet.get_document_percentage = new_instancemethod(_xapian.MSet_get_document_percentage, None, MSet) MSet_swigregister = _xapian.MSet_swigregister MSet_swigregister(MSet) class _MSetIterator(object): """ Iterator over a Xapian::MSet. """ thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr mset = property(_xapian._MSetIterator_mset_get, _xapian._MSetIterator_mset_set) off_from_end = property(_xapian._MSetIterator_off_from_end_get, _xapian._MSetIterator_off_from_end_set) def __init__(self): """ Create an unpositioned MSetIterator. Xapian::MSetIterator::MSetIterator() """ _xapian._MSetIterator_swiginit(self, _xapian.new__MSetIterator()) def get_rank(self): """ Return the MSet rank for the current position. Xapian::doccount Xapian::MSetIterator::get_rank() const The rank of mset[0] is mset.get_firstitem(). """ return _xapian._MSetIterator_get_rank(self) def get_document(self): """ Get the Document object for the current position. Xapian::Document Xapian::MSetIterator::get_document() const """ return _xapian._MSetIterator_get_document(self) def get_weight(self): """ Get the weight for the current position. double Xapian::MSetIterator::get_weight() const """ return _xapian._MSetIterator_get_weight(self) def get_collapse_key(self): """ Return the collapse key for the current position. std::string Xapian::MSetIterator::get_collapse_key() const If collapsing isn't in use, an empty string will be returned. """ return _xapian._MSetIterator_get_collapse_key(self) def get_collapse_count(self): """ Return a count of the number of collapses done onto the current key. Xapian::doccount Xapian::MSetIterator::get_collapse_count() const This starts at 0, and is incremented each time an item is eliminated because its key is the same as that of the current item (as returned by get_collapse_key()). Note that this is NOT necessarily one less than the total number of matching documents with this collapse key due to various optimisations implemented in the matcher - for example, it can skip documents completely if it can prove their weight wouldn't be enough to make the result set. You can say is that if get_collapse_count() > 0 then there are >= get_collapse_count() other documents with the current collapse key. But if get_collapse_count() == 0 then there may or may not be other such documents. """ return _xapian._MSetIterator_get_collapse_count(self) def get_sort_key(self): """ Return the sort key for the current position. std::string Xapian::MSetIterator::get_sort_key() const If sorting didn't use a key then an empty string will be returned. Added in Xapian 1.4.6. """ return _xapian._MSetIterator_get_sort_key(self) def get_percent(self): """ Convert the weight of the current iterator position to a percentage. int Xapian::MSetIterator::get_percent() const The matching document with the highest weight will get 100% if it matches all the weighted query terms, and proportionally less if it only matches some, and other weights are scaled by the same factor. Documents with a non-zero score will always score at least 1%. Note that these generally aren't percentages of anything meaningful (unless you use a custom weighting formula where they are!) """ return _xapian._MSetIterator_get_percent(self) def __str__(self): """ Return a string describing this object. std::string Xapian::MSetIterator::get_description() const """ return _xapian._MSetIterator___str__(self) __swig_destroy__ = _xapian.delete__MSetIterator _MSetIterator.get_rank = new_instancemethod(_xapian._MSetIterator_get_rank, None, _MSetIterator) _MSetIterator.get_document = new_instancemethod(_xapian._MSetIterator_get_document, None, _MSetIterator) _MSetIterator.get_weight = new_instancemethod(_xapian._MSetIterator_get_weight, None, _MSetIterator) _MSetIterator.get_collapse_key = new_instancemethod(_xapian._MSetIterator_get_collapse_key, None, _MSetIterator) _MSetIterator.get_collapse_count = new_instancemethod(_xapian._MSetIterator_get_collapse_count, None, _MSetIterator) _MSetIterator.get_sort_key = new_instancemethod(_xapian._MSetIterator_get_sort_key, None, _MSetIterator) _MSetIterator.get_percent = new_instancemethod(_xapian._MSetIterator_get_percent, None, _MSetIterator) _MSetIterator.__str__ = new_instancemethod(_xapian._MSetIterator___str__, None, _MSetIterator) _MSetIterator.__eq__ = new_instancemethod(_xapian._MSetIterator___eq__, None, _MSetIterator) _MSetIterator.__ne__ = new_instancemethod(_xapian._MSetIterator___ne__, None, _MSetIterator) _MSetIterator.equals = new_instancemethod(_xapian._MSetIterator_equals, None, _MSetIterator) _MSetIterator.get_docid = new_instancemethod(_xapian._MSetIterator_get_docid, None, _MSetIterator) _MSetIterator.next = new_instancemethod(_xapian._MSetIterator_next, None, _MSetIterator) _MSetIterator.prev = new_instancemethod(_xapian._MSetIterator_prev, None, _MSetIterator) _MSetIterator_swigregister = _xapian._MSetIterator_swigregister _MSetIterator_swigregister(_MSetIterator)
[docs]class ESet(object): """ Class representing a list of search results. """ thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self): """ Default constructor. Xapian::ESet::ESet() Creates an empty ESet, mostly useful as a placeholder. """ _xapian.ESet_swiginit(self, _xapian.new_ESet()) __swig_destroy__ = _xapian.delete_ESet def size(self): """ Return number of items in this ESet object. Xapian::doccount Xapian::ESet::size() const """ return _xapian.ESet_size(self) def empty(self): """ Return true if this ESet object is empty. bool Xapian::ESet::empty() const """ return _xapian.ESet_empty(self) def get_ebound(self): """ Return a bound on the full size of this ESet object. Xapian::termcount Xapian::ESet::get_ebound() const This is a bound on size() if get_eset() had been called with maxitems set high enough that all results were returned. """ return _xapian.ESet_get_ebound(self) def _begin(self): """ Return iterator pointing to the first item in this ESet. ESetIterator Xapian::ESet::begin() const """ return _xapian.ESet__begin(self) def _end(self): """ Return iterator pointing to just after the last item in this ESet. ESetIterator Xapian::ESet::end() const """ return _xapian.ESet__end(self) def back(self): """ Return iterator pointing to the last object in this ESet. ESetIterator Xapian::ESet::back() const """ return _xapian.ESet_back(self) def __str__(self): """ Return a string describing this object. std::string Xapian::ESet::get_description() const """ return _xapian.ESet___str__(self) items = property(_xapian.ESet_items_get)
ESet.size = new_instancemethod(_xapian.ESet_size, None, ESet) ESet.empty = new_instancemethod(_xapian.ESet_empty, None, ESet) ESet.get_ebound = new_instancemethod(_xapian.ESet_get_ebound, None, ESet) ESet._begin = new_instancemethod(_xapian.ESet__begin, None, ESet) ESet._end = new_instancemethod(_xapian.ESet__end, None, ESet) ESet.back = new_instancemethod(_xapian.ESet_back, None, ESet) ESet.__str__ = new_instancemethod(_xapian.ESet___str__, None, ESet) ESet_swigregister = _xapian.ESet_swigregister ESet_swigregister(ESet) class _ESetIterator(object): """ Iterator over a Xapian::ESet. """ thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr eset = property(_xapian._ESetIterator_eset_get, _xapian._ESetIterator_eset_set) off_from_end = property(_xapian._ESetIterator_off_from_end_get, _xapian._ESetIterator_off_from_end_set) def __init__(self): """ Create an unpositioned ESetIterator. Xapian::ESetIterator::ESetIterator() """ _xapian._ESetIterator_swiginit(self, _xapian.new__ESetIterator()) def get_weight(self): """ Get the weight for the current position. double Xapian::ESetIterator::get_weight() const """ return _xapian._ESetIterator_get_weight(self) def __str__(self): """ Return a string describing this object. std::string Xapian::ESetIterator::get_description() const """ return _xapian._ESetIterator___str__(self) __swig_destroy__ = _xapian.delete__ESetIterator _ESetIterator.get_weight = new_instancemethod(_xapian._ESetIterator_get_weight, None, _ESetIterator) _ESetIterator.__str__ = new_instancemethod(_xapian._ESetIterator___str__, None, _ESetIterator) _ESetIterator.__eq__ = new_instancemethod(_xapian._ESetIterator___eq__, None, _ESetIterator) _ESetIterator.__ne__ = new_instancemethod(_xapian._ESetIterator___ne__, None, _ESetIterator) _ESetIterator.equals = new_instancemethod(_xapian._ESetIterator_equals, None, _ESetIterator) _ESetIterator.get_term = new_instancemethod(_xapian._ESetIterator_get_term, None, _ESetIterator) _ESetIterator.next = new_instancemethod(_xapian._ESetIterator_next, None, _ESetIterator) _ESetIterator.prev = new_instancemethod(_xapian._ESetIterator_prev, None, _ESetIterator) _ESetIterator_swigregister = _xapian._ESetIterator_swigregister _ESetIterator_swigregister(_ESetIterator) def __eq__(*args): return _xapian.__eq__(*args) __eq__ = _xapian.__eq__ def __lt__(*args): return _xapian.__lt__(*args) __lt__ = _xapian.__lt__ def __gt__(*args): return _xapian.__gt__(*args) __gt__ = _xapian.__gt__ def __ge__(*args): return _xapian.__ge__(*args) __ge__ = _xapian.__ge__ def __le__(*args): return _xapian.__le__(*args) __le__ = _xapian.__le__ def __add__(*args): return _xapian.__add__(*args) __add__ = _xapian.__add__
[docs]class RSet(object): """ A relevance set (R-Set). This is the set of documents which are marked as relevant, for use in modifying the term weights, and in performing query expansion. """ thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self): """ Default constructor. Xapian::RSet::RSet() """ _xapian.RSet_swiginit(self, _xapian.new_RSet()) __swig_destroy__ = _xapian.delete_RSet def size(self): """ The number of documents in this R-Set. Xapian::doccount Xapian::RSet::size() const """ return _xapian.RSet_size(self) def empty(self): """ Test if this R-Set is empty. bool Xapian::RSet::empty() const """ return _xapian.RSet_empty(self) def add_document(self, *args): """ Add a document to the relevance set. void Xapian::RSet::add_document(const Xapian::MSetIterator &i) """ return _xapian.RSet_add_document(self, *args) def remove_document(self, *args): """ Remove a document from the relevance set. void Xapian::RSet::remove_document(const Xapian::MSetIterator &i) """ return _xapian.RSet_remove_document(self, *args) def contains(self, *args): """ Test if a given document in the relevance set. bool Xapian::RSet::contains(const Xapian::MSetIterator &i) const """ return _xapian.RSet_contains(self, *args) def __str__(self): """ Return a string describing this object. std::string Xapian::RSet::get_description() const """ return _xapian.RSet___str__(self)
RSet.size = new_instancemethod(_xapian.RSet_size, None, RSet) RSet.empty = new_instancemethod(_xapian.RSet_empty, None, RSet) RSet.add_document = new_instancemethod(_xapian.RSet_add_document, None, RSet) RSet.remove_document = new_instancemethod(_xapian.RSet_remove_document, None, RSet) RSet.contains = new_instancemethod(_xapian.RSet_contains, None, RSet) RSet.__str__ = new_instancemethod(_xapian.RSet___str__, None, RSet) RSet_swigregister = _xapian.RSet_swigregister RSet_swigregister(RSet)
[docs]class MatchDecider(object): """ Base class for matcher decision functor. """ thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self): """ Default constructor. Xapian::MatchDecider::MatchDecider() """ if self.__class__ == MatchDecider: _self = None else: _self = self _xapian.MatchDecider_swiginit(self, _xapian.new_MatchDecider(_self, )) __swig_destroy__ = _xapian.delete_MatchDecider def __disown__(self): self.this.disown() _xapian.disown_MatchDecider(self) return weakref_proxy(self)
MatchDecider.__call__ = new_instancemethod(_xapian.MatchDecider___call__, None, MatchDecider) MatchDecider_swigregister = _xapian.MatchDecider_swigregister MatchDecider_swigregister(MatchDecider)
[docs]class Enquire(object): """ This class provides an interface to the information retrieval system for the purpose of searching. Databases are usually opened lazily, so exceptions may not be thrown where you would expect them to be. You should catch Xapian::Error exceptions when calling any method in Xapian::Enquire. Parameters: ----------- Xapian::InvalidArgumentError: will be thrown if an invalid argument is supplied, for example, an unknown database type. """ thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self, database): """ Create a Xapian::Enquire object. Xapian::Enquire::Enquire(const Database &database, ErrorHandler *errorhandler_) This specification cannot be changed once the Xapian::Enquire is opened: you must create a new Xapian::Enquire object to access a different database, or set of databases. The database supplied must have been initialised (ie, must not be the result of calling the Database::Database() constructor). If you need to handle a situation where you have no databases gracefully, a database created with DB_BACKEND_INMEMORY can be passed here to provide a completely empty database. Parameters: ----------- database: Specification of the database or databases to use. errorhandler_: This parameter is deprecated (since Xapian 1.3.1), and as of 1.3.5 it's ignored completely. Parameters: ----------- Xapian::InvalidArgumentError: will be thrown if an empty Database object is supplied. """ _xapian.Enquire_swiginit(self, _xapian.new_Enquire(database)) __swig_destroy__ = _xapian.delete_Enquire
[docs] def set_query(self, query, qlen=0): """ Set the query to run. void Xapian::Enquire::set_query(const Xapian::Query &query, Xapian::termcount qlen=0) Parameters: ----------- query: the new query to run. qlen: the query length to use in weight calculations - by default the sum of the wqf of all terms is used. """ return _xapian.Enquire_set_query(self, query, qlen)
[docs] def get_query(self): """ Get the current query. const Xapian::Query& Xapian::Enquire::get_query() const If called before set_query(), this will return a default initialised Query object. """ return _xapian.Enquire_get_query(self)
[docs] def add_matchspy(self, spy): """ Add a matchspy. void Xapian::Enquire::add_matchspy(MatchSpy *spy) This matchspy will be called with some of the documents which match the query, during the match process. Exactly which of the matching documents are passed to it depends on exactly when certain optimisations occur during the match process, but it can be controlled to some extent by setting the checkatleast parameter to get_mset(). In particular, if there are enough matching documents, at least the number specified by checkatleast will be passed to the matchspy. This means that you can force the matchspy to be shown all matching documents by setting checkatleast to the number of documents in the database. Parameters: ----------- spy: The MatchSpy subclass to add. The caller must ensure that this remains valid while the Enquire object remains active, or until clear_matchspies() is called. """ return _xapian.Enquire_add_matchspy(self, spy)
[docs] def clear_matchspies(self): """ Remove all the matchspies. void Xapian::Enquire::clear_matchspies() """ return _xapian.Enquire_clear_matchspies(self)
def set_weighting_scheme(self, weight_): """ Set the weighting scheme to use for queries. void Xapian::Enquire::set_weighting_scheme(const Weight &weight_) Parameters: ----------- weight_: the new weighting scheme. If no weighting scheme is specified, the default is BM25 with the default parameters. """ return _xapian.Enquire_set_weighting_scheme(self, weight_) def set_expansion_scheme(self, eweightname_, expand_k_=1.0): """ Set the weighting scheme to use for expansion. void Xapian::Enquire::set_expansion_scheme(const std::string &eweightname_, double expand_k_=1.0) const If you don't call this method, the default is as if you'd used: get_expansion_scheme("trad"); Parameters: ----------- eweightname_: A string in lowercase specifying the name of the scheme to be used. The following schemes are currently available: "bo1" : The Bo1 scheme for query expansion. "trad" : The TradWeight scheme for query expansion. expand_k_: The parameter required for TradWeight query expansion. A default value of 1.0 is used if none is specified. """ return _xapian.Enquire_set_expansion_scheme(self, eweightname_, expand_k_) def set_collapse_key(self, collapse_key, collapse_max=1): """ Set the collapse key to use for queries. void Xapian::Enquire::set_collapse_key(Xapian::valueno collapse_key, Xapian::doccount collapse_max=1) Parameters: ----------- collapse_key: value number to collapse on - at most one MSet entry with each particular value will be returned (default is Xapian::BAD_VALUENO which means no collapsing). collapse_max: Max number of items with the same key to leave after collapsing (default 1). The MSet returned by get_mset() will have only the "best" (at most) collapse_max entries with each particular value of collapse_key ("best" being highest ranked - i.e. highest weight or highest sorting key). An example use might be to create a value for each document containing an MD5 hash of the document contents. Then duplicate documents from different sources can be eliminated at search time by collapsing with collapse_max = 1 (it's better to eliminate duplicates at index time, but this may not be always be possible - for example the search may be over more than one Xapian database). Another use is to group matches in a particular category (e.g. you might collapse a mailing list search on the Subject: so that there's only one result per discussion thread). In this case you can use get_collapse_count() to give the user some idea how many other results there are. And if you index the Subject: as a boolean term as well as putting it in a value, you can offer a link to a non-collapsed search restricted to that thread using a boolean filter. """ return _xapian.Enquire_set_collapse_key(self, collapse_key, collapse_max) ASCENDING = _xapian.Enquire_ASCENDING DESCENDING = _xapian.Enquire_DESCENDING DONT_CARE = _xapian.Enquire_DONT_CARE def set_docid_order(self, order): """ Set sort order for document IDs. void Xapian::Enquire::set_docid_order(docid_order order) This order only has an effect on documents which would otherwise have equal rank. When ordering by relevance without a sort key, this means documents with equal weight. For a boolean match with no sort key, this means all documents. And if a sort key is used, this means documents with the same sort key (and also equal weight if ordering on relevance before or after the sort key). Parameters: ----------- order: This can be: Xapian::Enquire::ASCENDING docids sort in ascending order (default) Xapian::Enquire::DESCENDING docids sort in descending order Xapian::Enquire::DONT_CARE docids sort in whatever order is most efficient for the backend Note: If you add documents in strict date order, then a boolean search - i.e. set_weighting_scheme(Xapian::BoolWeight()) - with set_docid_order(Xapian::Enquire::DESCENDING) is an efficient way to perform "sort by date, newest first", and with set_docid_order(Xapian::Enquire::ASCENDING) a very efficient way to perform "sort by date, oldest first". """ return _xapian.Enquire_set_docid_order(self, order) def set_cutoff(self, percent_cutoff, weight_cutoff=0): """ Set the percentage and/or weight cutoffs. void Xapian::Enquire::set_cutoff(int percent_cutoff, double weight_cutoff=0) Parameters: ----------- percent_cutoff: Minimum percentage score for returned documents. If a document has a lower percentage score than this, it will not appear in the MSet. If your intention is to return only matches which contain all the terms in the query, then it's more efficient to use Xapian::Query::OP_AND instead of Xapian::Query::OP_OR in the query than to use set_cutoff(100). (default 0 => no percentage cut-off). weight_cutoff: Minimum weight for a document to be returned. If a document has a lower score that this, it will not appear in the MSet. It is usually only possible to choose an appropriate weight for cutoff based on the results of a previous run of the same query; this is thus mainly useful for alerting operations. The other potential use is with a user specified weighting scheme. (default 0 => no weight cut-off). """ return _xapian.Enquire_set_cutoff(self, percent_cutoff, weight_cutoff) def set_sort_by_relevance(self): """ Set the sorting to be by relevance only. void Xapian::Enquire::set_sort_by_relevance() This is the default. """ return _xapian.Enquire_set_sort_by_relevance(self) def set_sort_by_value(self, sort_key, reverse): """ Set the sorting to be by value only. void Xapian::Enquire::set_sort_by_value(Xapian::valueno sort_key, bool reverse) Note that sorting by values uses a string comparison, so to use this to sort by a numeric value you'll need to store the numeric values in a manner which sorts appropriately. For example, you could use Xapian::sortable_serialise() (which works for floating point numbers as well as integers), or store numbers padded with leading zeros or spaces, or with the number of digits prepended. Parameters: ----------- sort_key: value number to sort on. reverse: If true, reverses the sort order. """ return _xapian.Enquire_set_sort_by_value(self, sort_key, reverse)
[docs] def set_sort_by_key(self, sorter, reverse): """ Set the sorting to be by key generated from values only. void Xapian::Enquire::set_sort_by_key(Xapian::KeyMaker *sorter, bool reverse) Parameters: ----------- sorter: The functor to use for generating keys. reverse: If true, reverses the sort order. """ return _xapian.Enquire_set_sort_by_key(self, sorter, reverse)
def set_sort_by_value_then_relevance(self, sort_key, reverse): """ Set the sorting to be by value, then by relevance for documents with the same value. void Xapian::Enquire::set_sort_by_value_then_relevance(Xapian::valueno sort_key, bool reverse) Note that sorting by values uses a string comparison, so to use this to sort by a numeric value you'll need to store the numeric values in a manner which sorts appropriately. For example, you could use Xapian::sortable_serialise() (which works for floating point numbers as well as integers), or store numbers padded with leading zeros or spaces, or with the number of digits prepended. Parameters: ----------- sort_key: value number to sort on. reverse: If true, reverses the sort order. """ return _xapian.Enquire_set_sort_by_value_then_relevance(self, sort_key, reverse)
[docs] def set_sort_by_key_then_relevance(self, sorter, reverse): """ Set the sorting to be by keys generated from values, then by relevance for documents with identical keys. void Xapian::Enquire::set_sort_by_key_then_relevance(Xapian::KeyMaker *sorter, bool reverse) Parameters: ----------- sorter: The functor to use for generating keys. reverse: If true, reverses the sort order. """ return _xapian.Enquire_set_sort_by_key_then_relevance(self, sorter, reverse)
def set_sort_by_relevance_then_value(self, sort_key, reverse): """ Set the sorting to be by relevance then value. void Xapian::Enquire::set_sort_by_relevance_then_value(Xapian::valueno sort_key, bool reverse) Note that sorting by values uses a string comparison, so to use this to sort by a numeric value you'll need to store the numeric values in a manner which sorts appropriately. For example, you could use Xapian::sortable_serialise() (which works for floating point numbers as well as integers), or store numbers padded with leading zeros or spaces, or with the number of digits prepended. Note that with the default BM25 weighting scheme parameters, non- identical documents will rarely have the same weight, so this setting will give very similar results to set_sort_by_relevance(). It becomes more useful with particular BM25 parameter settings (e.g. BM25Weight(1,0,1,0,0)) or custom weighting schemes. Parameters: ----------- sort_key: value number to sort on. reverse: If true, reverses the sort order of sort_key. Beware that in 1.2.16 and earlier, the sense of this parameter was incorrectly inverted and inconsistent with the other set_sort_by_... methods. This was fixed in 1.2.17, so make that version a minimum requirement if this detail matters to your application. """ return _xapian.Enquire_set_sort_by_relevance_then_value(self, sort_key, reverse)
[docs] def set_sort_by_relevance_then_key(self, sorter, reverse): """ Set the sorting to be by relevance, then by keys generated from values. void Xapian::Enquire::set_sort_by_relevance_then_key(Xapian::KeyMaker *sorter, bool reverse) Note that with the default BM25 weighting scheme parameters, non- identical documents will rarely have the same weight, so this setting will give very similar results to set_sort_by_relevance(). It becomes more useful with particular BM25 parameter settings (e.g. BM25Weight(1,0,1,0,0)) or custom weighting schemes. Parameters: ----------- sorter: The functor to use for generating keys. reverse: If true, reverses the sort order of the generated keys. Beware that in 1.2.16 and earlier, the sense of this parameter was incorrectly inverted and inconsistent with the other set_sort_by_... methods. This was fixed in 1.2.17, so make that version a minimum requirement if this detail matters to your application. """ return _xapian.Enquire_set_sort_by_relevance_then_key(self, sorter, reverse)
def set_time_limit(self, time_limit): """ Set a time limit for the match. void Xapian::Enquire::set_time_limit(double time_limit) Matches with check_at_least set high can take a long time in some cases. You can set a time limit on this, after which check_at_least will be turned off. Parameters: ----------- time_limit: time in seconds after which to disable check_at_least (default: 0.0 which means no time limit) Limitations: This feature is currently supported on platforms which support POSIX interval timers. Interaction with the remote backend when using multiple databases may have bugs. There's not currently a way to force the match to end after a certain time. """ return _xapian.Enquire_set_time_limit(self, time_limit) def get_mset(self, *args): """ Get (a portion of) the match set for the current query. MSet Xapian::Enquire::get_mset(Xapian::doccount first, Xapian::doccount maxitems, const RSet *omrset, const MatchDecider *mdecider=0) const Parameters: ----------- first: the first item in the result set to return. A value of zero corresponds to the first item returned being that with the highest score. A value of 10 corresponds to the first 10 items being ignored, and the returned items starting at the eleventh. maxitems: the maximum number of items to return. If you want all matches, then you can pass the result of calling get_doccount() on the Database object (though if you are doing this so you can filter results, you are likely to get much better performance by using Xapian's match-time filtering features instead). You can pass 0 for maxitems which will give you an empty MSet with valid statistics (such as get_matches_estimated()) calculated without looking at any postings, which is very quick, but means the estimates may be more approximate and the bounds may be much looser. omrset: the relevance set to use when performing the query. mdecider: a decision functor to use to decide whether a given document should be put in the MSet. A Xapian::MSet object containing the results of the query. Parameters: ----------- Xapian::InvalidArgumentError: See class documentation. """ return _xapian.Enquire_get_mset(self, *args) INCLUDE_QUERY_TERMS = _xapian.Enquire_INCLUDE_QUERY_TERMS USE_EXACT_TERMFREQ = _xapian.Enquire_USE_EXACT_TERMFREQ def get_eset(self, *args): """ Get the expand set for the given rset. ESet Xapian::Enquire::get_eset(Xapian::termcount maxitems, const RSet &rset, int flags, double k, const Xapian::ExpandDecider *edecider=NULL, double min_wt=0.0) const Parameters: ----------- maxitems: the maximum number of items to return. rset: the relevance set to use when performing the expand operation. flags: zero or more of these values |-ed together: Xapian::Enquire::INCLUDE_QUERY_TERMS query terms may be returned from expand Xapian::Enquire::USE_EXACT_TERMFREQ for multi dbs, calculate the exact termfreq; otherwise an approximation is used which can greatly improve efficiency, but still returns good results. k: the parameter k in the query expansion algorithm (default is 1.0) edecider: a decision functor to use to decide whether a given term should be put in the ESet min_wt: the minimum weight for included terms An ESet object containing the results of the expand. Parameters: ----------- Xapian::InvalidArgumentError: See class documentation. """ return _xapian.Enquire_get_eset(self, *args) def _get_matching_terms_begin(self, *args): """ Get terms which match a given document, by match set item. TermIterator Xapian::Enquire::get_matching_terms_begin(const MSetIterator &it) const This method returns the terms in the current query which match the given document. If the underlying database has suitable support, using this call (rather than passing a Xapian::docid) will enable the system to ensure that the correct data is returned, and that the document has not been deleted or changed since the query was performed. Parameters: ----------- it: The iterator for which to retrieve the matching terms. An iterator returning the terms which match the document. The terms will be returned (as far as this makes any sense) in the same order as the terms in the query. Terms will not occur more than once, even if they do in the query. Parameters: ----------- Xapian::InvalidArgumentError: See class documentation. Xapian::DocNotFoundError: The document specified could not be found in the database. """ return _xapian.Enquire__get_matching_terms_begin(self, *args) def _get_matching_terms_end(self, *args): """ End iterator corresponding to get_matching_terms_begin() TermIterator Xapian::Enquire::get_matching_terms_end(const MSetIterator &) const """ return _xapian.Enquire__get_matching_terms_end(self, *args) def __str__(self): """ Return a string describing this object. std::string Xapian::Enquire::get_description() const """ return _xapian.Enquire___str__(self)
Enquire.set_query = new_instancemethod(_xapian.Enquire_set_query, None, Enquire) Enquire.get_query = new_instancemethod(_xapian.