"""
Xapian is a highly adaptable toolkit which allows developers to easily
add advanced indexing and search facilities to their own
applications. It supports the Probabilistic Information Retrieval
model 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/>.
"""
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 2.0.5
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.



from sys import version_info
if version_info >= (3,0,0):
    new_instancemethod = lambda func, inst, cls: _xapian.SWIG_PyInstanceMethod_New(func)
else:
    from new import instancemethod as new_instancemethod
if version_info >= (2,6,0):
    def swig_import_helper():
        from os.path import dirname
        import imp
        fp = None
        try:
            fp, pathname, description = imp.find_module('_xapian', [dirname(__file__)])
        except ImportError:
            import _xapian
            return _xapian
        if fp is not None:
            try:
                _mod = imp.load_module('_xapian', fp, pathname, description)
            finally:
                fp.close()
            return _mod
    _xapian = swig_import_helper()
    del swig_import_helper
else:
    import _xapian
del version_info
try:
    _swig_property = property
except NameError:
    pass # Python < 2.2 doesn't have 'property'.
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
    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)
    if (not static):
        self.__dict__[name] = value
    else:
        raise AttributeError("You cannot add attributes to %s" % self)

def _swig_setattr(self,class_type,name,value):
    return _swig_setattr_nondynamic(self,class_type,name,value,0)

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(name)

def _swig_repr(self):
    try: strthis = "proxy of " + self.this.__repr__()
    except: strthis = ""
    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)

try:
    _object = object
    _newclass = 1
except AttributeError:
    class _object : pass
    _newclass = 0


def _swig_setattr_nondynamic_method(set):
    def set_attr(self,name,value):
        if (name == "thisown"): return self.this.own(value)
        if hasattr(self,name) or (name == "this"):
            set(self,name,value)
        else:
            raise AttributeError("You cannot add attributes to %s" % self)
    return set_attr


try:
    import weakref
    weakref_proxy = weakref.proxy
except:
    weakref_proxy = lambda x: x


class SwigPyIterator(object):
    thisown = _swig_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)

__version__ = '1.2.24'

BAD_VALUENO = _xapian.BAD_VALUENO
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
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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)


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
class PositionIterator(object):
    """
    An iterator pointing to items in a list of positions. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self, *args): 
        """
        Copying is allowed.

        Xapian::PositionIterator::PositionIterator(const PositionIterator &o)

        The internals are reference counted, so copying is also cheap. 
        """
        _xapian.PositionIterator_swiginit(self,_xapian.new_PositionIterator(*args))
    __swig_destroy__ = _xapian.delete_PositionIterator
    def skip_to(self, *args):
        """
        Advance the iterator to the specified termpos.

        void Xapian::PositionIterator::skip_to(Xapian::termpos pos)

        If the specified termpos isn't in the list, position ourselves on the
        first termpos after it (or at_end() if no greater term positions are
        present). 
        """
        return _xapian.PositionIterator_skip_to(self, *args)

    def __str__(self):
        """
        Return a string describing this object.

        std::string Xapian::PositionIterator::get_description() const 
        """
        return _xapian.PositionIterator___str__(self)

PositionIterator.get_termpos = new_instancemethod(_xapian.PositionIterator_get_termpos,None,PositionIterator)
PositionIterator.next = new_instancemethod(_xapian.PositionIterator_next,None,PositionIterator)
PositionIterator.equals = new_instancemethod(_xapian.PositionIterator_equals,None,PositionIterator)
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_swigregister = _xapian.PositionIterator_swigregister
PositionIterator_swigregister(PositionIterator)

class PostingIterator(object):
    """
    An iterator pointing to items in a list of postings. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    __swig_destroy__ = _xapian.delete_PostingIterator
    def __init__(self, *args): 
        """
        Copying is allowed.

        Xapian::PostingIterator::PostingIterator(const PostingIterator &other)

        The internals are reference counted, so copying is also cheap. 
        """
        _xapian.PostingIterator_swiginit(self,_xapian.new_PostingIterator(*args))
    def skip_to(self, *args):
        """
        Advance the iterator to the specified docid.

        void Xapian::PostingIterator::skip_to(Xapian::docid did)

        If the specified docid isn't in the list, position ourselves on the
        first document after it (or at_end() if no greater docids are
        present). 
        """
        return _xapian.PostingIterator_skip_to(self, *args)

    def get_doclength(self):
        """
        Get the length of the document at the current position in the
        postlist.

        Xapian::termcount Xapian::PostingIterator::get_doclength() const

        This information may be stored in the postlist, in which case this
        lookup should be extremely fast (indeed, not require further disk
        access). If the information is not present in the postlist, it will be
        retrieved from the database, at a greater performance cost. 
        """
        return _xapian.PostingIterator_get_doclength(self)

    def get_wdf(self):
        """
        Get the within document frequency of the document at the current
        position in the postlist.

        Xapian::termcount Xapian::PostingIterator::get_wdf() const 
        """
        return _xapian.PostingIterator_get_wdf(self)

    def positionlist_begin(self):
        """
        Return PositionIterator pointing to start of positionlist for current
        document.

        PositionIterator Xapian::PostingIterator::positionlist_begin() const

        """
        return _xapian.PostingIterator_positionlist_begin(self)

    def positionlist_end(self):
        """
        Return PositionIterator pointing to end of positionlist for current
        document.

        PositionIterator Xapian::PostingIterator::positionlist_end() const 
        """
        return _xapian.PostingIterator_positionlist_end(self)

    def __str__(self):
        """
        Return a string describing this object.

        std::string Xapian::PostingIterator::get_description() const 
        """
        return _xapian.PostingIterator___str__(self)

PostingIterator.skip_to = new_instancemethod(_xapian.PostingIterator_skip_to,None,PostingIterator)
PostingIterator.get_doclength = new_instancemethod(_xapian.PostingIterator_get_doclength,None,PostingIterator)
PostingIterator.get_wdf = new_instancemethod(_xapian.PostingIterator_get_wdf,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.__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.get_docid = new_instancemethod(_xapian.PostingIterator_get_docid,None,PostingIterator)
PostingIterator.next = new_instancemethod(_xapian.PostingIterator_next,None,PostingIterator)
PostingIterator.equals = new_instancemethod(_xapian.PostingIterator_equals,None,PostingIterator)
PostingIterator_swigregister = _xapian.PostingIterator_swigregister
PostingIterator_swigregister(PostingIterator)


def __eq__(*args):
  return _xapian.__eq__(*args)
__eq__ = _xapian.__eq__

def __ne__(*args):
  return _xapian.__ne__(*args)
__ne__ = _xapian.__ne__
class TermIterator(object):
    """
    An iterator pointing to items in a list of terms. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self, *args): 
        """
        Copying is allowed.

        Xapian::TermIterator::TermIterator(const TermIterator &other)

        The internals are reference counted, so copying is also cheap. 
        """
        _xapian.TermIterator_swiginit(self,_xapian.new_TermIterator(*args))
    __swig_destroy__ = _xapian.delete_TermIterator
    def skip_to(self, *args):
        """
        Advance the iterator to the specified term.

        void Xapian::TermIterator::skip_to(const std::string &tname)

        If the specified term isn't in the list, position ourselves on the
        first term after it (or at_end() if no greater terms are present). 
        """
        return _xapian.TermIterator_skip_to(self, *args)

    def get_wdf(self):
        """
        Return the wdf of the current term (if meaningful).

        Xapian::termcount Xapian::TermIterator::get_wdf() const

        The wdf (within document frequency) is the number of occurrences of a
        term in a particular document. 
        """
        return _xapian.TermIterator_get_wdf(self)

    def get_termfreq(self):
        """
        Return the term frequency of the current term (if meaningful).

        Xapian::doccount Xapian::TermIterator::get_termfreq() const

        The term frequency is the number of documents which a term indexes. 
        """
        return _xapian.TermIterator_get_termfreq(self)

    def positionlist_count(self):
        """
        Return length of positionlist for current term.

        Xapian::termcount Xapian::TermIterator::positionlist_count() const 
        """
        return _xapian.TermIterator_positionlist_count(self)

    def positionlist_begin(self):
        """
        Return PositionIterator pointing to start of positionlist for current
        term.

        PositionIterator Xapian::TermIterator::positionlist_begin() const 
        """
        return _xapian.TermIterator_positionlist_begin(self)

    def positionlist_end(self):
        """
        Return PositionIterator pointing to end of positionlist for current
        term.

        PositionIterator Xapian::TermIterator::positionlist_end() const 
        """
        return _xapian.TermIterator_positionlist_end(self)

    def __str__(self):
        """
        Return a string describing this object.

        std::string Xapian::TermIterator::get_description() const 
        """
        return _xapian.TermIterator___str__(self)

TermIterator.get_term = new_instancemethod(_xapian.TermIterator_get_term,None,TermIterator)
TermIterator.next = new_instancemethod(_xapian.TermIterator_next,None,TermIterator)
TermIterator.equals = new_instancemethod(_xapian.TermIterator_equals,None,TermIterator)
TermIterator.skip_to = new_instancemethod(_xapian.TermIterator_skip_to,None,TermIterator)
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.__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_swigregister = _xapian.TermIterator_swigregister
TermIterator_swigregister(TermIterator)

class ValueIterator(object):
    """
    Class for iterating over document values. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self, *args): 
        """
        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(*args))
    __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, *args):
        """
        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, *args)

    def check(self, *args):
        """
        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 brass and chert
        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
        depends 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, flint, 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, *args)

    def __str__(self):
        """
        Return a string describing this object.

        std::string Xapian::ValueIterator::get_description() const 
        """
        return _xapian.ValueIterator___str__(self)

ValueIterator.get_value = new_instancemethod(_xapian.ValueIterator_get_value,None,ValueIterator)
ValueIterator.next = new_instancemethod(_xapian.ValueIterator_next,None,ValueIterator)
ValueIterator.equals = new_instancemethod(_xapian.ValueIterator_equals,None,ValueIterator)
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_swigregister = _xapian.ValueIterator_swigregister
ValueIterator_swigregister(ValueIterator)

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 = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self, *args): 
        """
        Make a new empty Document.

        Xapian::Document::Document() 
        """
        _xapian.Document_swiginit(self,_xapian.new_Document(*args))
    __swig_destroy__ = _xapian.delete_Document
    def get_value(self, *args):
        """
        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, *args)

    def add_value(self, *args):
        """
        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, *args)

    def remove_value(self, *args):
        """
        Remove any value with the given number.

        void Xapian::Document::remove_value(Xapian::valueno slot) 
        """
        return _xapian.Document_remove_value(self, *args)

    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, *args):
        """
        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, *args)

    def add_posting(self, *args):
        """
        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, *args)

    def add_term(self, *args):
        """
        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, *args)

    def add_boolean_term(self, *args):
        """
        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, *args)

    def remove_posting(self, *args):
        """
        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, *args)

    def remove_term(self, *args):
        """
        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, *args)

    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().

        ValueIteratorEnd_ 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_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(*args):
  return _xapian.Document_unserialise(*args)
Document_unserialise = _xapian.Document_unserialise

class PostingSource(object):
    """
    Base class which provides an "external" source of postings. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self): 
        if self.__class__ == PostingSource:
            _self = None
        else:
            _self = self
        _xapian.PostingSource_swiginit(self,_xapian.new_PostingSource(_self, ))
    __swig_destroy__ = _xapian.delete_PostingSource
    def get_termfreq_min(self):
        """
        A lower bound on the number of documents this object can return.

        virtual Xapian::doccount Xapian::PostingSource::get_termfreq_min()
        const =0

        Xapian will always call init() on a PostingSource before calling this
        for the first time. 
        """
        return _xapian.PostingSource_get_termfreq_min(self)

    def get_termfreq_est(self):
        """
        An estimate of the number of documents this object can return.

        virtual Xapian::doccount Xapian::PostingSource::get_termfreq_est()
        const =0

        It must always be true that:

        get_termfreq_min() <= get_termfreq_est() <= get_termfreq_max()

        Xapian will always call init() on a PostingSource before calling this
        for the first time. 
        """
        return _xapian.PostingSource_get_termfreq_est(self)

    def get_termfreq_max(self):
        """
        An upper bound on the number of documents this object can return.

        virtual Xapian::doccount Xapian::PostingSource::get_termfreq_max()
        const =0

        Xapian will always call init() on a PostingSource before calling this
        for the first time. 
        """
        return _xapian.PostingSource_get_termfreq_max(self)

    def get_maxweight(self):
        """
        Return the currently set upper bound on what get_weight() can return.

        Xapian::weight Xapian::PostingSource::get_maxweight() const 
        """
        return _xapian.PostingSource_get_maxweight(self)

    def get_weight(self):
        """
        Return the weight contribution for the current document.

        virtual Xapian::weight Xapian::PostingSource::get_weight() const

        This default implementation always returns 0, for convenience when
        implementing "weight-less" PostingSource subclasses.

        This method may assume that it will only be called when there is a
        "current document". In detail: Xapian will always call init() on a
        PostingSource before calling this for the first time. It will also
        only call this if the PostingSource reports that it is pointing to a
        valid document (ie, it will not call it before calling at least one of
        next(), skip_to() or check(), and will ensure that the PostingSource
        is not at the end by calling at_end()). 
        """
        return _xapian.PostingSource_get_weight(self)

    def get_docid(self):
        """
        Return the current docid.

        virtual Xapian::docid Xapian::PostingSource::get_docid() const =0

        This method may assume that it will only be called when there is a
        "current document". See  get_weight() for details.

        Note: in the case of a multi-database search, the returned docid
        should be in the single subdatabase relevant to this posting source.
        See the  init() method for details. 
        """
        return _xapian.PostingSource_get_docid(self)

    def next(self, *args):
        """
        Advance the current position to the next matching document.

        virtual void Xapian::PostingSource::next(Xapian::weight min_wt)=0

        The PostingSource starts before the first entry in the list, so next()
        must be called before any methods which need the context of the
        current position.

        Xapian will always call init() on a PostingSource before calling this
        for the first time.

        Parameters:
        -----------

        min_wt:  The minimum weight contribution that is needed (this is just
        a hint which subclasses may ignore). 
        """
        return _xapian.PostingSource_next(self, *args)

    def skip_to(self, *args):
        """
        Advance to the specified docid.

        virtual void Xapian::PostingSource::skip_to(Xapian::docid did,
        Xapian::weight min_wt)

        If the specified docid isn't in the list, position ourselves on the
        first document after it (or at_end() if no greater docids are
        present).

        If the current position is already the specified docid, this method
        will leave the position unmodified.

        If the specified docid is earlier than the current position, the
        behaviour is unspecified. A sensible behaviour would be to leave the
        current position unmodified, but it is also reasonable to move to the
        specified docid.

        The default implementation calls next() repeatedly, which works but
        skip_to() can often be implemented much more efficiently.

        Xapian will always call init() on a PostingSource before calling this
        for the first time.

        Note: in the case of a multi-database search, the docid specified is
        the docid in the single subdatabase relevant to this posting source.
        See the  init() method for details.

        Parameters:
        -----------

        did:  The document id to advance to.

        min_wt:  The minimum weight contribution that is needed (this is just
        a hint which subclasses may ignore). 
        """
        return _xapian.PostingSource_skip_to(self, *args)

    def check(self, *args):
        """
        Check if the specified docid occurs.

        virtual bool Xapian::PostingSource::check(Xapian::docid did,
        Xapian::weight min_wt)

        The caller is required to ensure that the specified document id did
        actually exists in the database. If it does, it must move to that
        document id, and return true. If it does not, it may either:

        return true, having moved to a definite position (including
        "at_end"), which must be the same position as skip_to() would have
        moved to.

        or

        return false, having moved to an "indeterminate" position, such that
        a subsequent call to next() or skip_to() will move to the next
        matching position after did.

        Generally, this method should act like skip_to() and return true if
        that can be done at little extra cost.

        Otherwise it should simply check if a particular docid is present,
        returning true if it is, and false if it isn't.

        The default implementation calls skip_to() and always returns true.

        Xapian will always call init() on a PostingSource before calling this
        for the first time.

        Note: in the case of a multi-database search, the docid specified is
        the docid in the single subdatabase relevant to this posting source.
        See the  init() method for details.

        Parameters:
        -----------

        did:  The document id to check.

        min_wt:  The minimum weight contribution that is needed (this is just
        a hint which subclasses may ignore). 
        """
        return _xapian.PostingSource_check(self, *args)

    def at_end(self):
        """
        Return true if the current position is past the last entry in this
        list.

        virtual bool Xapian::PostingSource::at_end() const =0

        At least one of  next(),  skip_to() or  check() will be called before
        this method is first called. 
        """
        return _xapian.PostingSource_at_end(self)

    def name(self):
        """
        Name of the posting source class.

        virtual std::string Xapian::PostingSource::name() const

        This is used when serialising and unserialising posting sources; for
        example, for performing remote searches.

        If the subclass is in a C++ namespace, the namespace should be
        included in the name, using "::" as a separator. For example, for a
        PostingSource subclass called "FooPostingSource" in the "Xapian"
        namespace the result of this call should be
        "Xapian::FooPostingSource".

        This should only be implemented if serialise() and unserialise() are
        also implemented. The default implementation returns an empty string.

        If this returns an empty string, Xapian will assume that serialise()
        and unserialise() are not implemented. 
        """
        return _xapian.PostingSource_name(self)

    def init(self, *args):
        """
        Set this PostingSource to the start of the list of postings.

        virtual void Xapian::PostingSource::init(const Database &db)=0

        This is called automatically by the matcher prior to each query being
        processed.

        If a PostingSource is used for multiple searches,  init() will
        therefore be called multiple times, and must handle this by using the
        database passed in the most recent call.

        Parameters:
        -----------

        db:  The database which the PostingSource should iterate through.

        Note: the database supplied to this method must not be modified: in
        particular, the reopen() method should not be called on it.

        Note: in the case of a multi-database search, a separate PostingSource
        will be used for each database (the separate PostingSources will be
        obtained using  clone()), and each PostingSource will be passed one of
        the sub-databases as the db parameter here. The db parameter will
        therefore always refer to a single database. All docids passed to, or
        returned from, the PostingSource refer to docids in that single
        database, rather than in the multi- database. 
        """
        return _xapian.PostingSource_init(self, *args)

    def __str__(self):
        """
        Return a string describing this object.

        virtual std::string Xapian::PostingSource::get_description() const

        This default implementation returns a generic answer. This default it
        provided to avoid forcing those deriving their own PostingSource
        subclass from having to implement this (they may not care what
        get_description() gives for their subclass). 
        """
        return _xapian.PostingSource___str__(self)

    def __disown__(self):
        self.this.disown()
        _xapian.disown_PostingSource(self)
        return weakref_proxy(self)
PostingSource.get_termfreq_min = new_instancemethod(_xapian.PostingSource_get_termfreq_min,None,PostingSource)
PostingSource.get_termfreq_est = new_instancemethod(_xapian.PostingSource_get_termfreq_est,None,PostingSource)
PostingSource.get_termfreq_max = new_instancemethod(_xapian.PostingSource_get_termfreq_max,None,PostingSource)
PostingSource.get_maxweight = new_instancemethod(_xapian.PostingSource_get_maxweight,None,PostingSource)
PostingSource.get_weight = new_instancemethod(_xapian.PostingSource_get_weight,None,PostingSource)
PostingSource.get_docid = new_instancemethod(_xapian.PostingSource_get_docid,None,PostingSource)
PostingSource.next = new_instancemethod(_xapian.PostingSource_next,None,PostingSource)
PostingSource.skip_to = new_instancemethod(_xapian.PostingSource_skip_to,None,PostingSource)
PostingSource.check = new_instancemethod(_xapian.PostingSource_check,None,PostingSource)
PostingSource.at_end = new_instancemethod(_xapian.PostingSource_at_end,None,PostingSource)
PostingSource.name = new_instancemethod(_xapian.PostingSource_name,None,PostingSource)
PostingSource.init = new_instancemethod(_xapian.PostingSource_init,None,PostingSource)
PostingSource.__str__ = new_instancemethod(_xapian.PostingSource___str__,None,PostingSource)
PostingSource_swigregister = _xapian.PostingSource_swigregister
PostingSource_swigregister(PostingSource)

class ValuePostingSource(PostingSource):
    """
    A posting source which generates weights from a value slot.

    This is a base class for classes which generate weights using values
    stored in the specified slot. For example, ValueWeightPostingSource
    uses sortable_unserialise to convert values directly to weights.

    The upper bound on the weight returned is set to DBL_MAX. Subclasses
    should call set_maxweight() in their init() methods after calling
    ValuePostingSource::init() if they know a tighter bound on the weight.

    """
    thisown = _swig_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 ValuePostingSource.

        Xapian::ValuePostingSource::ValuePostingSource(Xapian::valueno slot_)

        Parameters:
        -----------

        slot_:  The value slot to read values from. 
        """
        _xapian.ValuePostingSource_swiginit(self,_xapian.new_ValuePostingSource(*args))
    def get_database(self):
        """
        The database we're reading values from.

        Xapian::Database Xapian::ValuePostingSource::get_database() const

        Added in 1.2.23 and 1.3.5. 
        """
        return _xapian.ValuePostingSource_get_database(self)

    def get_slot(self):
        """
        The slot we're reading values from.

        Xapian::valueno Xapian::ValuePostingSource::get_slot() const

        Added in 1.2.23 and 1.3.5. 
        """
        return _xapian.ValuePostingSource_get_slot(self)

    def get_value(self):
        """
        Read current value.

        std::string Xapian::ValuePostingSource::get_value() const

        Added in 1.2.23 and 1.3.5. 
        """
        return _xapian.ValuePostingSource_get_value(self)

    def done(self):
        """
        End the iteration.

        void Xapian::ValuePostingSource::done()

        Calls to at_end() will return true after calling this method.

        Added in 1.2.23 and 1.3.5. 
        """
        return _xapian.ValuePostingSource_done(self)

    def get_started(self):
        """
        Flag indicating if we've started (true if we have).

        bool Xapian::ValuePostingSource::get_started() const

        Added in 1.2.23 and 1.3.5. 
        """
        return _xapian.ValuePostingSource_get_started(self)

    def set_termfreq_min(self, *args):
        """
        Set a lower bound on the term frequency.

        void Xapian::ValuePostingSource::set_termfreq_min(Xapian::doccount
        termfreq_min_)

        Subclasses should set this if they are overriding the next(),
        skip_to() or check() methods to return fewer documents.

        Added in 1.2.23 and 1.3.5. 
        """
        return _xapian.ValuePostingSource_set_termfreq_min(self, *args)

    def set_termfreq_est(self, *args):
        """
        An estimate of the term frequency.

        void Xapian::ValuePostingSource::set_termfreq_est(Xapian::doccount
        termfreq_est_)

        Subclasses should set this if they are overriding the next(),
        skip_to() or check() methods.

        Added in 1.2.23 and 1.3.5. 
        """
        return _xapian.ValuePostingSource_set_termfreq_est(self, *args)

    def set_termfreq_max(self, *args):
        """
        An upper bound on the term frequency.

        void Xapian::ValuePostingSource::set_termfreq_max(Xapian::doccount
        termfreq_max_)

        Subclasses should set this if they are overriding the next(),
        skip_to() or check() methods.

        Added in 1.2.23 and 1.3.5. 
        """
        return _xapian.ValuePostingSource_set_termfreq_max(self, *args)

    __swig_destroy__ = _xapian.delete_ValuePostingSource
ValuePostingSource.get_database = new_instancemethod(_xapian.ValuePostingSource_get_database,None,ValuePostingSource)
ValuePostingSource.get_slot = new_instancemethod(_xapian.ValuePostingSource_get_slot,None,ValuePostingSource)
ValuePostingSource.get_value = new_instancemethod(_xapian.ValuePostingSource_get_value,None,ValuePostingSource)
ValuePostingSource.done = new_instancemethod(_xapian.ValuePostingSource_done,None,ValuePostingSource)
ValuePostingSource.get_started = new_instancemethod(_xapian.ValuePostingSource_get_started,None,ValuePostingSource)
ValuePostingSource.set_termfreq_min = new_instancemethod(_xapian.ValuePostingSource_set_termfreq_min,None,ValuePostingSource)
ValuePostingSource.set_termfreq_est = new_instancemethod(_xapian.ValuePostingSource_set_termfreq_est,None,ValuePostingSource)
ValuePostingSource.set_termfreq_max = new_instancemethod(_xapian.ValuePostingSource_set_termfreq_max,None,ValuePostingSource)
ValuePostingSource_swigregister = _xapian.ValuePostingSource_swigregister
ValuePostingSource_swigregister(ValuePostingSource)

class ValueWeightPostingSource(ValuePostingSource):
    """
    A posting source which reads weights from a value slot.

    This returns entries for all documents in the given database which
    have a non empty values in the specified slot. It returns a weight
    calculated by applying sortable_unserialise to the value stored in the
    slot (so the values stored should probably have been calculated by
    applying sortable_serialise to a floating point number at index time).

    The upper bound on the weight returned is set using the upper bound on
    the values in the specified slot, or DBL_MAX if value bounds aren't
    supported by the current backend.

    For efficiency, this posting source doesn't check that the stored
    values are valid in any way, so it will never raise an exception due
    to invalid stored values. In particular, it doesn't ensure that the
    unserialised values are positive, which is a requirement for weights.
    The behaviour if the slot contains values which unserialise to
    negative values is undefined. 
    """
    thisown = _swig_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 ValueWeightPostingSource.

        Xapian::ValueWeightPostingSource::ValueWeightPostingSource(Xapian::valueno
        slot_)

        Parameters:
        -----------

        slot_:  The value slot to read values from. 
        """
        _xapian.ValueWeightPostingSource_swiginit(self,_xapian.new_ValueWeightPostingSource(*args))
    __swig_destroy__ = _xapian.delete_ValueWeightPostingSource
ValueWeightPostingSource_swigregister = _xapian.ValueWeightPostingSource_swigregister
ValueWeightPostingSource_swigregister(ValueWeightPostingSource)

class DecreasingValueWeightPostingSource(ValueWeightPostingSource):
    """
    Read weights from a value which is known to decrease as docid
    increases.

    This posting source can be used, like ValueWeightPostingSource, to add
    a weight contribution to a query based on the values stored in a slot.
    The values in the slot must be serialised as by  sortable_serialise().

    However, this posting source is additionally given a range of document
    IDs, within which the weight is known to be decreasing. ie, for all
    documents with ids A and B within this range (including the
    endpoints), where A is less than B, the weight of A is less than or
    equal to the weight of B. This can allow the posting source to skip to
    the end of the range quickly if insufficient weight is left in the
    posting source for a particular source.

    By default, the range is assumed to cover all document IDs.

    The ordering property can be arranged at index time, or by sorting an
    indexed database to produce a new, sorted, database. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self, *args): 
        """
        Xapian::DecreasingValueWeightPostingSource::DecreasingValueWeightPostingSource(Xapian::valueno
        slot_, Xapian::docid range_start_=0, Xapian::docid range_end_=0) 
        """
        _xapian.DecreasingValueWeightPostingSource_swiginit(self,_xapian.new_DecreasingValueWeightPostingSource(*args))
    __swig_destroy__ = _xapian.delete_DecreasingValueWeightPostingSource
DecreasingValueWeightPostingSource_swigregister = _xapian.DecreasingValueWeightPostingSource_swigregister
DecreasingValueWeightPostingSource_swigregister(DecreasingValueWeightPostingSource)

class ValueMapPostingSource(ValuePostingSource):
    """
    A posting source which looks up weights in a map using values as the
    key.

    This allows will return entries for all documents in the given
    database which have a value in the slot specified. The values will be
    mapped to the corresponding weight in the weight map. If there is no
    mapping for a particular value, the default weight will be returned
    (which itself defaults to 0.0). 
    """
    thisown = _swig_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 ValueWeightPostingSource.

        Xapian::ValueMapPostingSource::ValueMapPostingSource(Xapian::valueno
        slot_)

        Parameters:
        -----------

        slot_:  The value slot to read values from. 
        """
        _xapian.ValueMapPostingSource_swiginit(self,_xapian.new_ValueMapPostingSource(*args))
    def add_mapping(self, *args):
        """
        Add a mapping.

        void Xapian::ValueMapPostingSource::add_mapping(const std::string
        &key, double wt)

        Parameters:
        -----------

        key:  The key looked up from the value slot.

        wt:  The weight to give this key. 
        """
        return _xapian.ValueMapPostingSource_add_mapping(self, *args)

    def clear_mappings(self):
        """
        Clear all mappings.

        void Xapian::ValueMapPostingSource::clear_mappings() 
        """
        return _xapian.ValueMapPostingSource_clear_mappings(self)

    def set_default_weight(self, *args):
        """
        Set a default weight for document values not in the map.

        void Xapian::ValueMapPostingSource::set_default_weight(double wt)

        Parameters:
        -----------

        wt:  The weight to set as the default. 
        """
        return _xapian.ValueMapPostingSource_set_default_weight(self, *args)

    __swig_destroy__ = _xapian.delete_ValueMapPostingSource
ValueMapPostingSource.add_mapping = new_instancemethod(_xapian.ValueMapPostingSource_add_mapping,None,ValueMapPostingSource)
ValueMapPostingSource.clear_mappings = new_instancemethod(_xapian.ValueMapPostingSource_clear_mappings,None,ValueMapPostingSource)
ValueMapPostingSource.set_default_weight = new_instancemethod(_xapian.ValueMapPostingSource_set_default_weight,None,ValueMapPostingSource)
ValueMapPostingSource_swigregister = _xapian.ValueMapPostingSource_swigregister
ValueMapPostingSource_swigregister(ValueMapPostingSource)

class FixedWeightPostingSource(PostingSource):
    """
    A posting source which returns a fixed weight for all documents.

    This returns entries for all documents in the given database, with a
    fixed weight (specified by a parameter to the constructor). 
    """
    thisown = _swig_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 FixedWeightPostingSource.

        Xapian::FixedWeightPostingSource::FixedWeightPostingSource(Xapian::weight
        wt)

        Parameters:
        -----------

        wt:  The fixed weight to return. 
        """
        _xapian.FixedWeightPostingSource_swiginit(self,_xapian.new_FixedWeightPostingSource(*args))
    __swig_destroy__ = _xapian.delete_FixedWeightPostingSource
FixedWeightPostingSource_swigregister = _xapian.FixedWeightPostingSource_swigregister
FixedWeightPostingSource_swigregister(FixedWeightPostingSource)

class MSet(object):
    """
    A match set ( MSet).

    This class represents (a portion of) the results of a query. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self, *args): 
        """
        Copying is allowed (and is cheap).

        Xapian::MSet::MSet(const MSet &other) 
        """
        _xapian.MSet_swiginit(self,_xapian.new_MSet(*args))
    __swig_destroy__ = _xapian.delete_MSet
    def fetch(self, *args):
        """
        Fetch all the items in the MSet.

        void Xapian::MSet::fetch() const 
        """
        return _xapian.MSet_fetch(self, *args)

    def convert_to_percent(self, *args):
        """
        Return the percentage score for a particular item.

        Xapian::percent Xapian::MSet::convert_to_percent(const MSetIterator
        &it) const 
        """
        return _xapian.MSet_convert_to_percent(self, *args)

    def get_termfreq(self, *args):
        """
        Return the term frequency of the given query term.

        Xapian::doccount Xapian::MSet::get_termfreq(const std::string &tname)
        const

        Parameters:
        -----------

        tname:  The term to look for.

        This is sometimes more efficient than asking the database directly for
        the term frequency - in particular, if the term was in the query, its
        frequency will usually be cached in the MSet. 
        """
        return _xapian.MSet_get_termfreq(self, *args)

    def get_termweight(self, *args):
        """
        Return the term weight of the given query term.

        Xapian::weight Xapian::MSet::get_termweight(const std::string &tname)
        const

        Parameters:
        -----------

        tname:  The term to look for.

        Parameters:
        -----------

        Xapian::InvalidArgumentError:  is thrown if the term was not in the
        query. 
        """
        return _xapian.MSet_get_termweight(self, *args)

    def get_firstitem(self):
        """
        The index of the first item in the result which was put into the MSet.

        Xapian::doccount Xapian::MSet::get_firstitem() const

        This corresponds to the parameter "first" specified in
        Xapian::Enquire::get_mset(). A value of 0 corresponds to the highest
        result being the first item in the MSet. 
        """
        return _xapian.MSet_get_firstitem(self)

    def get_matches_lower_bound(self):
        """
        A lower bound on the number of documents in the database which match
        the query.

        Xapian::doccount Xapian::MSet::get_matches_lower_bound() const

        This figure takes into account collapsing of duplicates, and weighting
        cutoff values.

        This number is usually considerably less than the actual number of
        documents which match the query. 
        """
        return _xapian.MSet_get_matches_lower_bound(self)

    def get_matches_estimated(self):
        """
        An estimate for the number of documents in the database which match
        the query.

        Xapian::doccount Xapian::MSet::get_matches_estimated() const

        This figure takes into account collapsing of duplicates, and weighting
        cutoff values.

        This value is returned because there is sometimes a request to display
        such information. However, our experience is that presenting this
        value to users causes them to worry about the large number of results,
        rather than how useful those at the top of the result set are, and is
        thus undesirable. 
        """
        return _xapian.MSet_get_matches_estimated(self)

    def get_matches_upper_bound(self):
        """
        An upper bound on the number of documents in the database which match
        the query.

        Xapian::doccount Xapian::MSet::get_matches_upper_bound() const

        This figure takes into account collapsing of duplicates, and weighting
        cutoff values.

        This number is usually considerably greater than the actual number of
        documents which match the query. 
        """
        return _xapian.MSet_get_matches_upper_bound(self)

    def get_uncollapsed_matches_lower_bound(self):
        """
        A lower bound on the number of documents in the database which would
        match the query if collapsing wasn't used.

        Xapian::doccount Xapian::MSet::get_uncollapsed_matches_lower_bound()
        const 
        """
        return _xapian.MSet_get_uncollapsed_matches_lower_bound(self)

    def get_uncollapsed_matches_estimated(self):
        """
        A estimate of the number of documents in the database which would
        match the query if collapsing wasn't used.

        Xapian::doccount Xapian::MSet::get_uncollapsed_matches_estimated()
        const 
        """
        return _xapian.MSet_get_uncollapsed_matches_estimated(self)

    def get_uncollapsed_matches_upper_bound(self):
        """
        A upper bound on the number of documents in the database which would
        match the query if collapsing wasn't used.

        Xapian::doccount Xapian::MSet::get_uncollapsed_matches_upper_bound()
        const 
        """
        return _xapian.MSet_get_uncollapsed_matches_upper_bound(self)

    def get_max_possible(self):
        """
        The maximum possible weight in the MSet.

        Xapian::weight Xapian::MSet::get_max_possible() const

        This weight is likely not to be attained in the set of results, but
        represents an upper bound on the weight which a document could attain
        for the given query. 
        """
        return _xapian.MSet_get_max_possible(self)

    def get_max_attained(self):
        """
        The greatest weight which is attained by any document in the database.

        Xapian::weight Xapian::MSet::get_max_attained() const

        If firstitem == 0 and the primary ordering is by relevance, this is
        the weight of the first entry in the MSet.

        If no documents are found by the query, this will be 0.

        Note that calculation of max_attained requires calculation of at least
        one result item - therefore, if no items were requested when the query
        was performed (by specifying maxitems = 0 in
        Xapian::Enquire::get_mset()), this value will be 0. 
        """
        return _xapian.MSet_get_max_attained(self)

    def size(self):
        """
        The number of items in this MSet.

        Xapian::doccount Xapian::MSet::size() const 
        """
        return _xapian.MSet_size(self)

    def empty(self):
        """
        Test if this MSet is empty.

        bool Xapian::MSet::empty() const 
        """
        return _xapian.MSet_empty(self)

    def begin(self):
        """
        Iterator for the items in this MSet.

        MSetIterator Xapian::MSet::begin() const 
        """
        return _xapian.MSet_begin(self)

    def end(self):
        """
        End iterator corresponding to begin()

        MSetIterator Xapian::MSet::end() const 
        """
        return _xapian.MSet_end(self)

    def back(self):
        """
        Iterator pointing to the last element of this MSet.

        MSetIterator Xapian::MSet::back() const 
        """
        return _xapian.MSet_back(self)

    def _get_hit_internal(self, *args):
        """
        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, *args)

    def __str__(self):
        """
        Return a string describing this object.

        std::string Xapian::MSet::get_description() const 
        """
        return _xapian.MSet___str__(self)

    items = _swig_property(_xapian.MSet_items_get)
MSet.fetch = new_instancemethod(_xapian.MSet_fetch,None,MSet)
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_possible = new_instancemethod(_xapian.MSet_get_max_possible,None,MSet)
MSet.get_max_attained = new_instancemethod(_xapian.MSet_get_max_attained,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._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.get_document = new_instancemethod(_xapian.MSet_get_document,None,MSet)
MSet.get_docid = new_instancemethod(_xapian.MSet_get_docid,None,MSet)
MSet.__str__ = new_instancemethod(_xapian.MSet___str__,None,MSet)
MSet.__cmp__ = new_instancemethod(_xapian.MSet___cmp__,None,MSet)
MSet_swigregister = _xapian.MSet_swigregister
MSet_swigregister(MSet)

class MSetIterator(object):
    """
    An iterator pointing to items in an MSet.

    This is used for access to individual results of a match. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self, *args): 
        """
        Copying is allowed (and is cheap).

        Xapian::MSetIterator::MSetIterator(const MSetIterator &other) 
        """
        _xapian.MSetIterator_swiginit(self,_xapian.new_MSetIterator(*args))
    __swig_destroy__ = _xapian.delete_MSetIterator
    def get_document(self):
        """
        Get a Xapian::Document object for the current position.

        Xapian::Document Xapian::MSetIterator::get_document() const

        This method returns a Xapian::Document object which provides the
        information about the document pointed to by the MSetIterator.

        If the underlying database has suitable support, using this call
        (rather than asking the database for a document based on its document
        ID) 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.

        A Xapian::Document object containing the document data.

        Parameters:
        -----------

        Xapian::DocNotFoundError:  The document specified could not be found
        in the database. 
        """
        return _xapian.MSetIterator_get_document(self)

    def get_rank(self):
        """
        Get the rank of the document at the current position.

        Xapian::doccount Xapian::MSetIterator::get_rank() const

        The rank is the position that this document is at in the ordered list
        of results of the query. The result is 0-based - i.e. the top-ranked
        document has a rank of 0. 
        """
        return _xapian.MSetIterator_get_rank(self)

    def get_weight(self):
        """
        Get the weight of the document at the current position.

        Xapian::weight Xapian::MSetIterator::get_weight() const 
        """
        return _xapian.MSetIterator_get_weight(self)

    def get_collapse_key(self):
        """
        Get the collapse key for this document.

        std::string Xapian::MSetIterator::get_collapse_key() const 
        """
        return _xapian.MSetIterator_get_collapse_key(self)

    def get_collapse_count(self):
        """
        Get an estimate of the number of documents that have been collapsed
        into this one.

        Xapian::doccount Xapian::MSetIterator::get_collapse_count() const

        The estimate will always be less than or equal to the actual number of
        other documents satisfying the match criteria with the same collapse
        key as this document.

        This method may return 0 even though there are other documents with
        the same collapse key which satisfying the match criteria. However if
        this method returns non-zero, there definitely are other such
        documents. So this method may be used to inform the user that there
        are "at least N other matches in this group", or to control whether
        to offer a "show other documents in this group" feature (but note
        that it may not offer it in every case where it would show other
        documents). 
        """
        return _xapian.MSetIterator_get_collapse_count(self)

    def get_percent(self):
        """
        This returns the weight of the document as a percentage score.

        Xapian::percent Xapian::MSetIterator::get_percent() const

        The return value will be an integer in the range 0 to 100: 0 meaning
        that the item did not match the query at all.

        The intention is that the highest weighted document will get 100 if it
        matches all the weight-contributing terms in the query. However,
        currently it may get a lower percentage score if you use a
        MatchDecider and the sorting is primarily by value. In this case, the
        percentage for a particular document may vary depending on the first,
        max_size, and checkatleast parameters passed to Enquire::get_mset()
        (this bug is hard to fix without having to apply the MatchDecider to
        potentially many more documents, which is potentially costly). 
        """
        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)

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.equals = new_instancemethod(_xapian.MSetIterator_equals,None,MSetIterator)
MSetIterator.get_document = new_instancemethod(_xapian.MSetIterator_get_document,None,MSetIterator)
MSetIterator.get_rank = new_instancemethod(_xapian.MSetIterator_get_rank,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_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_swigregister = _xapian.MSetIterator_swigregister
MSetIterator_swigregister(MSetIterator)

class ESet(object):
    """
    Class representing an ordered set of expand terms (an ESet).

    This set represents the results of an expand operation, which is
    performed by Xapian::Enquire::get_eset(). 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self, *args): 
        """
        Copying is allowed (and is cheap).

        Xapian::ESet::ESet(const ESet &other) 
        """
        _xapian.ESet_swiginit(self,_xapian.new_ESet(*args))
    __swig_destroy__ = _xapian.delete_ESet
    def get_ebound(self):
        """
        A lower bound on the number of terms which are in the full set of
        results of the expand.

        Xapian::termcount Xapian::ESet::get_ebound() const

        This will be greater than or equal to size() 
        """
        return _xapian.ESet_get_ebound(self)

    def size(self):
        """
        The number of terms in this E-Set.

        Xapian::termcount Xapian::ESet::size() const 
        """
        return _xapian.ESet_size(self)

    def empty(self):
        """
        Test if this E-Set is empty.

        bool Xapian::ESet::empty() const 
        """
        return _xapian.ESet_empty(self)

    def begin(self):
        """
        Iterator for the terms in this E-Set.

        ESetIterator Xapian::ESet::begin() const 
        """
        return _xapian.ESet_begin(self)

    def end(self):
        """
        End iterator corresponding to begin()

        ESetIterator Xapian::ESet::end() const 
        """
        return _xapian.ESet_end(self)

    def back(self):
        """
        Iterator pointing to the last element of this E-Set.

        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 = _swig_property(_xapian.ESet_items_get)
ESet.get_ebound = new_instancemethod(_xapian.ESet_get_ebound,None,ESet)
ESet.size = new_instancemethod(_xapian.ESet_size,None,ESet)
ESet.empty = new_instancemethod(_xapian.ESet_empty,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):
    """
    Iterate through terms in the ESet. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self, *args): 
        """
        Copying is allowed (and is cheap).

        Xapian::ESetIterator::ESetIterator(const ESetIterator &other) 
        """
        _xapian.ESetIterator_swiginit(self,_xapian.new_ESetIterator(*args))
    __swig_destroy__ = _xapian.delete_ESetIterator
    def get_weight(self):
        """
        Get the weight of the term at the current position.

        Xapian::weight 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)

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.equals = new_instancemethod(_xapian.ESetIterator_equals,None,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_swigregister = _xapian.ESetIterator_swigregister
ESetIterator_swigregister(ESetIterator)

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 = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self, *args): 
        """
        Default constructor.

        Xapian::RSet::RSet() 
        """
        _xapian.RSet_swiginit(self,_xapian.new_RSet(*args))
    __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)

class MatchDecider(object):
    """
    Base class for matcher decision functor. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    __swig_destroy__ = _xapian.delete_MatchDecider
    def __init__(self): 
        if self.__class__ == MatchDecider:
            _self = None
        else:
            _self = self
        _xapian.MatchDecider_swiginit(self,_xapian.new_MatchDecider(_self, ))
    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)

class ExpandDecider(object):
    """
    Virtual base class for expand decider functor. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    __swig_destroy__ = _xapian.delete_ExpandDecider
    def __init__(self): 
        if self.__class__ == ExpandDecider:
            _self = None
        else:
            _self = self
        _xapian.ExpandDecider_swiginit(self,_xapian.new_ExpandDecider(_self, ))
    def __disown__(self):
        self.this.disown()
        _xapian.disown_ExpandDecider(self)
        return weakref_proxy(self)
ExpandDecider.__call__ = new_instancemethod(_xapian.ExpandDecider___call__,None,ExpandDecider)
ExpandDecider_swigregister = _xapian.ExpandDecider_swigregister
ExpandDecider_swigregister(ExpandDecider)

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 = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self, *args): 
        """
        Create a Xapian::Enquire object.

        Xapian::Enquire::Enquire(const Database &database, ErrorHandler
        *errorhandler_=0)

        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 index gracefully, a database
        created with InMemory::open() can be passed here, which represents a
        completely empty database.

        Parameters:
        -----------

        database:  Specification of the database or databases to use.

        errorhandler_:  A pointer to the error handler to use. Ownership of
        the object pointed to is not assumed by the Xapian::Enquire object -
        the user should delete the Xapian::ErrorHandler object after the
        Xapian::Enquire object is deleted. To use no error handler, this
        parameter should be 0.

        Parameters:
        -----------

        Xapian::InvalidArgumentError:  will be thrown if an empty Database
        object is supplied. 
        """
        _xapian.Enquire_swiginit(self,_xapian.new_Enquire(*args))
    __swig_destroy__ = _xapian.delete_Enquire
    def set_query(self, *args):
        """
        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, *args)

    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)

    def add_matchspy(self, *args):
        """
        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, *args)

    def clear_matchspies(self):
        """
        Remove all the matchspies.

        void Xapian::Enquire::clear_matchspies() 
        """
        return _xapian.Enquire_clear_matchspies(self)

    def set_weighting_scheme(self, *args):
        """
        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, *args)

    def set_collapse_key(self, *args):
        """
        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, *args)

    ASCENDING = _xapian.Enquire_ASCENDING
    DESCENDING = _xapian.Enquire_DESCENDING
    DONT_CARE = _xapian.Enquire_DONT_CARE
    def set_docid_order(self, *args):
        """
        Set the direction in which documents are ordered by document id in the
        returned MSet.

        void Xapian::Enquire::set_docid_order(docid_order order)

        This order only has an effect on documents which would otherwise have
        equal rank. For a weighted probabilistic match with no sort value,
        this means documents with equal weight. For a boolean match, with no
        sort value, this means all documents. And if a sort value is used,
        this means documents with equal sort value (and also equal weight if
        ordering on relevance after the sort).

        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, *args)

    def set_cutoff(self, *args):
        """
        Set the percentage and/or weight cutoffs.

        void Xapian::Enquire::set_cutoff(Xapian::percent percent_cutoff,
        Xapian::weight 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, *args)

    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, *args):
        """
        void
        Xapian::Enquire::set_sort_by_value(Xapian::valueno sort_key) 
        """
        return _xapian.Enquire_set_sort_by_value(self, *args)

    def set_sort_by_value_then_relevance(self, *args):
        """
        void
        Xapian::Enquire::set_sort_by_value_then_relevance(Xapian::valueno
        sort_key) 
        """
        return _xapian.Enquire_set_sort_by_value_then_relevance(self, *args)

    def set_sort_by_relevance_then_value(self, *args):
        """
        void
        Xapian::Enquire::set_sort_by_relevance_then_value(Xapian::valueno
        sort_key) 
        """
        return _xapian.Enquire_set_sort_by_relevance_then_value(self, *args)

    def set_sort_by_key(self, *args):
        """
        void
        Xapian::Enquire::set_sort_by_key(Xapian::KeyMaker *sorter) 
        """
        return _xapian.Enquire_set_sort_by_key(self, *args)

    def set_sort_by_key_then_relevance(self, *args):
        """
        void
        Xapian::Enquire::set_sort_by_key_then_relevance(Xapian::KeyMaker
        *sorter) 
        """
        return _xapian.Enquire_set_sort_by_key_then_relevance(self, *args)

    def set_sort_by_relevance_then_key(self, *args):
        """
        void
        Xapian::Enquire::set_sort_by_relevance_then_key(Xapian::KeyMaker
        *sorter) 
        """
        return _xapian.Enquire_set_sort_by_relevance_then_key(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
        &omrset, int flags, double k, const Xapian::ExpandDecider *edecider,
        Xapian::weight min_wt) const

        Parameters:
        -----------

        maxitems:  the maximum number of items to return.

        omrset:  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.Enquire_get_query,None,Enquire)
Enquire.add_matchspy = new_instancemethod(_xapian.Enquire_add_matchspy,None,Enquire)
Enquire.clear_matchspies = new_instancemethod(_xapian.Enquire_clear_matchspies,None,Enquire)
Enquire.set_weighting_scheme = new_instancemethod(_xapian.Enquire_set_weighting_scheme,None,Enquire)
Enquire.set_collapse_key = new_instancemethod(_xapian.Enquire_set_collapse_key,None,Enquire)
Enquire.set_docid_order = new_instancemethod(_xapian.Enquire_set_docid_order,None,Enquire)
Enquire.set_cutoff = new_instancemethod(_xapian.Enquire_set_cutoff,None,Enquire)
Enquire.set_sort_by_relevance = new_instancemethod(_xapian.Enquire_set_sort_by_relevance,None,Enquire)
Enquire.set_sort_by_value = new_instancemethod(_xapian.Enquire_set_sort_by_value,None,Enquire)
Enquire.set_sort_by_value_then_relevance = new_instancemethod(_xapian.Enquire_set_sort_by_value_then_relevance,None,Enquire)
Enquire.set_sort_by_relevance_then_value = new_instancemethod(_xapian.Enquire_set_sort_by_relevance_then_value,None,Enquire)
Enquire.set_sort_by_key = new_instancemethod(_xapian.Enquire_set_sort_by_key,None,Enquire)
Enquire.set_sort_by_key_then_relevance = new_instancemethod(_xapian.Enquire_set_sort_by_key_then_relevance,None,Enquire)
Enquire.set_sort_by_relevance_then_key = new_instancemethod(_xapian.Enquire_set_sort_by_relevance_then_key,None,Enquire)
Enquire.get_mset = new_instancemethod(_xapian.Enquire_get_mset,None,Enquire)
Enquire.get_eset = new_instancemethod(_xapian.Enquire_get_eset,None,Enquire)
Enquire.get_matching_terms_begin = new_instancemethod(_xapian.Enquire_get_matching_terms_begin,None,Enquire)
Enquire.get_matching_terms_end = new_instancemethod(_xapian.Enquire_get_matching_terms_end,None,Enquire)
Enquire.__str__ = new_instancemethod(_xapian.Enquire___str__,None,Enquire)
Enquire_swigregister = _xapian.Enquire_swigregister
Enquire_swigregister(Enquire)

class Registry(object):
    """
    Registry for user subclasses.

    This class provides a way for the remote server to look up user
    subclasses when unserialising. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self, *args): 
        """
        Default constructor.

        Xapian::Registry::Registry()

        The registry will contain all standard subclasses of user-subclassable
        classes. 
        """
        _xapian.Registry_swiginit(self,_xapian.new_Registry(*args))
    __swig_destroy__ = _xapian.delete_Registry
    def register_weighting_scheme(self, *args):
        """
        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, *args)

    def get_weighting_scheme(self, *args):
        """
        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, *args)

    def register_posting_source(self, *args):
        """
        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, *args)

    def get_posting_source(self, *args):
        """
        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, *args)

    def register_match_spy(self, *args):
        """
        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, *args)

    def get_match_spy(self, *args):
        """
        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, *args)

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_swigregister = _xapian.Registry_swigregister
Registry_swigregister(Registry)

class Weight(object):
    """
    Abstract base class for weighting schemes. 
    """
    thisown = _swig_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_Weight
    def name(self):
        """
        Return the name of this weighting scheme.

        virtual std::string Xapian::Weight::name() const

        This name is used by the remote backend. It is passed along with the
        serialised parameters to the remote server so that it knows which
        class to create.

        Return the full namespace-qualified name of your class here - if your
        class is called FooWeight, return "FooWeight" from this method (
        Xapian::BM25Weight returns "Xapian::BM25Weight" here).

        If you don't want to support the remote backend, you can use the
        default implementation which simply returns an empty string. 
        """
        return _xapian.Weight_name(self)

    def get_sumpart(self, *args):
        """
        Calculate the weight contribution for this object's term to a
        document.

        virtual Xapian::weight Xapian::Weight::get_sumpart(Xapian::termcount
        wdf, Xapian::termcount doclen) const =0

        The parameters give information about the document which may be used
        in the calculations:

        Parameters:
        -----------

        wdf:  The within document frequency of the term in the document.

        doclen:  The document's length (unnormalised). 
        """
        return _xapian.Weight_get_sumpart(self, *args)

    def get_maxpart(self):
        """
        Return an upper bound on what get_sumpart() can return for any
        document.

        virtual Xapian::weight Xapian::Weight::get_maxpart() const =0

        This information is used by the matcher to perform various
        optimisations, so strive to make the bound as tight as possible. 
        """
        return _xapian.Weight_get_maxpart(self)

    def get_sumextra(self, *args):
        """
        Calculate the term-independent weight component for a document.

        virtual Xapian::weight Xapian::Weight::get_sumextra(Xapian::termcount
        doclen) const =0

        The parameter gives information about the document which may be used
        in the calculations:

        Parameters:
        -----------

        doclen:  The document's length (unnormalised). 
        """
        return _xapian.Weight_get_sumextra(self, *args)

    def get_maxextra(self):
        """
        Return an upper bound on what get_sumextra() can return for any
        document.

        virtual Xapian::weight Xapian::Weight::get_maxextra() const =0

        This information is used by the matcher to perform various
        optimisations, so strive to make the bound as tight as possible. 
        """
        return _xapian.Weight_get_maxextra(self)

Weight.name = new_instancemethod(_xapian.Weight_name,None,Weight)
Weight.get_sumpart = new_instancemethod(_xapian.Weight_get_sumpart,None,Weight)
Weight.get_maxpart = new_instancemethod(_xapian.Weight_get_maxpart,None,Weight)
Weight.get_sumextra = new_instancemethod(_xapian.Weight_get_sumextra,None,Weight)
Weight.get_maxextra = new_instancemethod(_xapian.Weight_get_maxextra,None,Weight)
Weight_swigregister = _xapian.Weight_swigregister
Weight_swigregister(Weight)

class BoolWeight(Weight):
    """
    Class implementing a "boolean" weighting scheme.

    This weighting scheme gives all documents zero weight. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self): 
        """
        Construct a BoolWeight.

        Xapian::BoolWeight::BoolWeight() 
        """
        _xapian.BoolWeight_swiginit(self,_xapian.new_BoolWeight())
    __swig_destroy__ = _xapian.delete_BoolWeight
BoolWeight_swigregister = _xapian.BoolWeight_swigregister
BoolWeight_swigregister(BoolWeight)

class BM25Weight(Weight):
    """
    Xapian::Weight subclass implementing the BM25 probabilistic formula.

    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self, *args): 
        """Xapian::BM25Weight::BM25Weight() """
        _xapian.BM25Weight_swiginit(self,_xapian.new_BM25Weight(*args))
    __swig_destroy__ = _xapian.delete_BM25Weight
BM25Weight_swigregister = _xapian.BM25Weight_swigregister
BM25Weight_swigregister(BM25Weight)

class TradWeight(Weight):
    """
    Xapian::Weight subclass implementing the traditional probabilistic
    formula.

    This class implements the "traditional" Probabilistic Weighting
    scheme, as described by the early papers on Probabilistic Retrieval.
    BM25 generally gives better results.

    TradWeight(k) is equivalent to BM25Weight(k, 0, 0, 1, 0), except that
    the latter returns weights (k+1) times larger. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self, k=1.0): 
        """
        Construct a TradWeight.

        Xapian::TradWeight::TradWeight(double k=1.0)

        Parameters:
        -----------

        k:  A non-negative parameter controlling how influential within-
        document- frequency (wdf) and document length are. k=0 means that wdf
        and document length don't affect the weights. The larger k is, the
        more they do. (default 1) 
        """
        _xapian.TradWeight_swiginit(self,_xapian.new_TradWeight(k))
    __swig_destroy__ = _xapian.delete_TradWeight
TradWeight_swigregister = _xapian.TradWeight_swigregister
TradWeight_swigregister(TradWeight)

class MatchSpy(object):
    """
    Abstract base class for match spies.

    The subclasses will generally accumulate information seen during the
    match, to calculate aggregate functions, or other profiles of the
    matching documents. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self): 
        if self.__class__ == MatchSpy:
            _self = None
        else:
            _self = self
        _xapian.MatchSpy_swiginit(self,_xapian.new_MatchSpy(_self, ))
    __swig_destroy__ = _xapian.delete_MatchSpy
    def name(self):
        """
        Return the name of this match spy.

        virtual std::string Xapian::MatchSpy::name() const

        This name is used by the remote backend. It is passed with the
        serialised parameters to the remote server so that it knows which
        class to create.

        Return the full namespace-qualified name of your class here - if your
        class is called MyApp::FooMatchSpy, return "MyApp::FooMatchSpy" from
        this method.

        If you don't want to support the remote backend in your match spy, you
        can use the default implementation which simply throws
        Xapian::UnimplementedError. 
        """
        return _xapian.MatchSpy_name(self)

    def merge_results(self, *args):
        """
        Unserialise some results, and merge them into this matchspy.

        virtual void Xapian::MatchSpy::merge_results(const std::string &s)

        The order in which results are merged should not be significant, since
        this order is not specified (and will vary depending on the speed of
        the search in each sub-database).

        If you don't want to support the remote backend in your match spy, you
        can use the default implementation which simply throws
        Xapian::UnimplementedError.

        Parameters:
        -----------

        s:  A string containing the serialised results. 
        """
        return _xapian.MatchSpy_merge_results(self, *args)

    def __str__(self):
        """
        Return a string describing this object.

        virtual std::string Xapian::MatchSpy::get_description() const

        This default implementation returns a generic answer, to avoid forcing
        those deriving their own MatchSpy subclasses from having to implement
        this (they may not care what get_description() gives for their
        subclass). 
        """
        return _xapian.MatchSpy___str__(self)

    def __disown__(self):
        self.this.disown()
        _xapian.disown_MatchSpy(self)
        return weakref_proxy(self)
MatchSpy.__call__ = new_instancemethod(_xapian.MatchSpy___call__,None,MatchSpy)
MatchSpy.name = new_instancemethod(_xapian.MatchSpy_name,None,MatchSpy)
MatchSpy.merge_results = new_instancemethod(_xapian.MatchSpy_merge_results,None,MatchSpy)
MatchSpy.__str__ = new_instancemethod(_xapian.MatchSpy___str__,None,MatchSpy)
MatchSpy_swigregister = _xapian.MatchSpy_swigregister
MatchSpy_swigregister(MatchSpy)

class ValueCountMatchSpy(MatchSpy):
    """
    Class for counting the frequencies of values in the matching
    documents. 
    """
    thisown = _swig_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 MatchSpy which counts the values in a particular slot.

        Xapian::ValueCountMatchSpy::ValueCountMatchSpy(Xapian::valueno slot_)

        """
        _xapian.ValueCountMatchSpy_swiginit(self,_xapian.new_ValueCountMatchSpy(*args))
    def get_total(self):
        """
        Return the total number of documents tallied.

        size_t Xapian::ValueCountMatchSpy::get_total() const 
        """
        return _xapian.ValueCountMatchSpy_get_total(self)

    def values_begin(self):
        """
        Get an iterator over the values seen in the slot.

        TermIterator Xapian::ValueCountMatchSpy::values_begin() const

        Items will be returned in ascending alphabetical order.

        During the iteration, the frequency of the current value can be
        obtained with the get_termfreq() method on the iterator. 
        """
        return _xapian.ValueCountMatchSpy_values_begin(self)

    def values_end(self):
        """
        End iterator corresponding to values_begin()

        TermIterator Xapian::ValueCountMatchSpy::values_end() const 
        """
        return _xapian.ValueCountMatchSpy_values_end(self)

    def top_values_begin(self, *args):
        """
        Get an iterator over the most frequent values seen in the slot.

        TermIterator Xapian::ValueCountMatchSpy::top_values_begin(size_t
        maxvalues) const

        Items will be returned in descending order of frequency. Values with
        the same frequency will be returned in ascending alphabetical order.

        During the iteration, the frequency of the current value can be
        obtained with the get_termfreq() method on the iterator.

        Parameters:
        -----------

        maxvalues:  The maximum number of values to return. 
        """
        return _xapian.ValueCountMatchSpy_top_values_begin(self, *args)

    def top_values_end(self, *args):
        """
        End iterator corresponding to top_values_begin()

        TermIterator Xapian::ValueCountMatchSpy::top_values_end(size_t) const

        """
        return _xapian.ValueCountMatchSpy_top_values_end(self, *args)

    __swig_destroy__ = _xapian.delete_ValueCountMatchSpy
ValueCountMatchSpy.get_total = new_instancemethod(_xapian.ValueCountMatchSpy_get_total,None,ValueCountMatchSpy)
ValueCountMatchSpy.values_begin = new_instancemethod(_xapian.ValueCountMatchSpy_values_begin,None,ValueCountMatchSpy)
ValueCountMatchSpy.values_end = new_instancemethod(_xapian.ValueCountMatchSpy_values_end,None,ValueCountMatchSpy)
ValueCountMatchSpy.top_values_begin = new_instancemethod(_xapian.ValueCountMatchSpy_top_values_begin,None,ValueCountMatchSpy)
ValueCountMatchSpy.top_values_end = new_instancemethod(_xapian.ValueCountMatchSpy_top_values_end,None,ValueCountMatchSpy)
ValueCountMatchSpy_swigregister = _xapian.ValueCountMatchSpy_swigregister
ValueCountMatchSpy_swigregister(ValueCountMatchSpy)

class Database(object):
    """
    This class is used to access a database, or a group of databases.

    For searching, this class is used in conjunction with an Enquire
    object.

    Parameters:
    -----------

    InvalidArgumentError:  will be thrown if an invalid argument is
    supplied, for example, an unknown database type.

    DatabaseOpeningError:  may be thrown if the database cannot be opened
    (for example, a required file cannot be found).

    DatabaseVersionError:  may be thrown if the database is in an
    unsupported format (for example, created by a newer version of Xapian
    which uses an incompatible format). 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def add_database(self, *args):
        """
        Add an existing database (or group of databases) to those accessed by
        this object.

        void Xapian::Database::add_database(const Database &database)

        Parameters:
        -----------

        database:  the database(s) to add. 
        """
        return _xapian.Database_add_database(self, *args)

    __swig_destroy__ = _xapian.delete_Database
    def __init__(self, *args): 
        """
        Copying is allowed.

        Xapian::Database::Database(const Database &other)

        The internals are reference counted, so copying is cheap.

        Parameters:
        -----------

        other:  The object to copy. 
        """
        _xapian.Database_swiginit(self,_xapian.new_Database(*args))
    def reopen(self):
        """
        Re-open the database.

        void Xapian::Database::reopen()

        This re-opens the database(s) to the latest available version(s). It
        can be used either to make sure the latest results are returned, or to
        recover from a Xapian::DatabaseModifiedError.

        Calling reopen() on a database which has been closed (with  close())
        will always raise a Xapian::DatabaseError. 
        """
        return _xapian.Database_reopen(self)

    def close(self):
        """
        Close the database.

        virtual void Xapian::Database::close()

        This closes the database and closes all its file handles.

        For a WritableDatabase, if a transaction is active it will be aborted,
        while if no transaction is active commit() will be implicitly called.
        Also the write lock is released.

        Closing a database cannot be undone - in particular, calling reopen()
        after close() will not reopen it, but will instead throw a
        Xapian::DatabaseError exception.

        Calling close() again on a database which has already been closed has
        no effect (and doesn't raise an exception).

        After close() has been called, calls to other methods of the database,
        and to methods of other objects associated with the database, will
        either:

        behave exactly as they would have done if the database had not been
        closed (this can only happen if all the required data is cached)

        raise a Xapian::DatabaseError exception indicating that the database
        is closed.

        The reason for this behaviour is that otherwise we'd have to check
        that the database is still open on every method call on every object
        associated with a Database, when in many cases they are working on
        data which has already been loaded and so they are able to just behave
        correctly.

        This method was added in Xapian 1.1.0. 
        """
        return _xapian.Database_close(self)

    def __str__(self):
        """
        Return a string describing this object.

        virtual std::string Xapian::Database::get_description() const 
        """
        return _xapian.Database___str__(self)

    def postlist_begin(self, *args):
        """
        An iterator pointing to the start of the postlist for a given term.

        PostingIterator Xapian::Database::postlist_begin(const std::string
        &tname) const

        Parameters:
        -----------

        tname:  The termname to iterate postings for. If the term name is the
        empty string, the iterator returned will list all the documents in the
        database. Such an iterator will always return a WDF value of 1, since
        there is no obvious meaning for this quantity in this case. 
        """
        return _xapian.Database_postlist_begin(self, *args)

    def postlist_end(self, *args):
        """
        Corresponding end iterator to postlist_begin().

        PostingIterator Xapian::Database::postlist_end(const std::string &)
        const 
        """
        return _xapian.Database_postlist_end(self, *args)

    def termlist_begin(self, *args):
        """
        An iterator pointing to the start of the termlist for a given
        document.

        TermIterator Xapian::Database::termlist_begin(Xapian::docid did) const

        Parameters:
        -----------

        did:  The document id of the document to iterate terms for. 
        """
        return _xapian.Database_termlist_begin(self, *args)

    def termlist_end(self, *args):
        """
        Corresponding end iterator to termlist_begin().

        TermIterator Xapian::Database::termlist_end(Xapian::docid) const 
        """
        return _xapian.Database_termlist_end(self, *args)

    def positionlist_begin(self, *args):
        """
        An iterator pointing to the start of the position list for a given
        term in a given document.

        PositionIterator Xapian::Database::positionlist_begin(Xapian::docid
        did, const std::string &tname) const 
        """
        return _xapian.Database_positionlist_begin(self, *args)

    def positionlist_end(self, *args):
        """
        Corresponding end iterator to positionlist_begin().

        PositionIterator Xapian::Database::positionlist_end(Xapian::docid,
        const std::string &) const 
        """
        return _xapian.Database_positionlist_end(self, *args)

    def allterms_begin(self, *args):
        """
        An iterator which runs across all terms with a given prefix.

        TermIterator Xapian::Database::allterms_begin(const std::string
        &prefix) const

        This is functionally similar to getting an iterator with
        allterms_begin() and then calling skip_to(prefix) on that iterator to
        move to the start of the prefix, but is more convenient (because it
        detects the end of the prefixed terms), and may be more efficient than
        simply calling skip_to() after opening the iterator, particularly for
        remote databases.

        Parameters:
        -----------

        prefix:  The prefix to restrict the returned terms to. 
        """
        return _xapian.Database_allterms_begin(self, *args)

    def allterms_end(self, *args):
        """
        Corresponding end iterator to allterms_begin(prefix).

        TermIterator Xapian::Database::allterms_end(const std::string &) const

        """
        return _xapian.Database_allterms_end(self, *args)

    def get_doccount(self):
        """
        Get the number of documents in the database.

        Xapian::doccount Xapian::Database::get_doccount() const 
        """
        return _xapian.Database_get_doccount(self)

    def get_lastdocid(self):
        """
        Get the highest document id which has been used in the database.

        Xapian::docid Xapian::Database::get_lastdocid() const 
        """
        return _xapian.Database_get_lastdocid(self)

    def get_avlength(self):
        """
        Get the average length of the documents in the database.

        Xapian::doclength Xapian::Database::get_avlength() const 
        """
        return _xapian.Database_get_avlength(self)

    def get_termfreq(self, *args):
        """
        Get the number of documents in the database indexed by a given term.

        Xapian::doccount Xapian::Database::get_termfreq(const std::string
        &tname) const 
        """
        return _xapian.Database_get_termfreq(self, *args)

    def term_exists(self, *args):
        """
        Check if a given term exists in the database.

        bool Xapian::Database::term_exists(const std::string &tname) const

        Parameters:
        -----------

        tname:  The term to test the existence of.

        true if and only if the term exists in the database. This is the same
        as (get_termfreq(tname) != 0), but will often be more efficient. 
        """
        return _xapian.Database_term_exists(self, *args)

    def get_collection_freq(self, *args):
        """
        Return the total number of occurrences of the given term.

        Xapian::termcount Xapian::Database::get_collection_freq(const
        std::string &tname) const

        This is the sum of the number of occurrences of the term in each
        document it indexes: i.e., the sum of the within document frequencies
        of the term.

        Parameters:
        -----------

        tname:  The term whose collection frequency is being requested. 
        """
        return _xapian.Database_get_collection_freq(self, *args)

    def get_value_freq(self, *args):
        """
        Return the frequency of a given value slot.

        Xapian::doccount Xapian::Database::get_value_freq(Xapian::valueno
        slot) const

        This is the number of documents which have a (non-empty) value stored
        in the slot.

        Parameters:
        -----------

        slot:  The value slot to examine.

        Parameters:
        -----------

        UnimplementedError:  The frequency of the value isn't available for
        this database type. 
        """
        return _xapian.Database_get_value_freq(self, *args)

    def get_value_lower_bound(self, *args):
        """
        Get a lower bound on the values stored in the given value slot.

        std::string Xapian::Database::get_value_lower_bound(Xapian::valueno
        slot) const

        If there are no values stored in the given value slot, this will
        return an empty string.

        If the lower bound isn't available for the given database type, this
        will return the lowest possible bound - the empty string.

        Parameters:
        -----------

        slot:  The value slot to examine. 
        """
        return _xapian.Database_get_value_lower_bound(self, *args)

    def get_value_upper_bound(self, *args):
        """
        Get an upper bound on the values stored in the given value slot.

        std::string Xapian::Database::get_value_upper_bound(Xapian::valueno
        slot) const

        If there are no values stored in the given value slot, this will
        return an empty string.

        Parameters:
        -----------

        slot:  The value slot to examine.

        Parameters:
        -----------

        UnimplementedError:  The upper bound of the values isn't available for
        this database type. 
        """
        return _xapian.Database_get_value_upper_bound(self, *args)

    def get_doclength_lower_bound(self):
        """
        Get a lower bound on the length of a document in this DB.

        Xapian::termcount Xapian::Database::get_doclength_lower_bound() const

        This bound does not include any zero-length documents. 
        """
        return _xapian.Database_get_doclength_lower_bound(self)

    def get_doclength_upper_bound(self):
        """
        Get an upper bound on the length of a document in this DB.

        Xapian::termcount Xapian::Database::get_doclength_upper_bound() const

        """
        return _xapian.Database_get_doclength_upper_bound(self)

    def get_wdf_upper_bound(self, *args):
        """
        Get an upper bound on the wdf of term term.

        Xapian::termcount Xapian::Database::get_wdf_upper_bound(const
        std::string &term) const 
        """
        return _xapian.Database_get_wdf_upper_bound(self, *args)

    def valuestream_begin(self, *args):
        """
        Return an iterator over the value in slot slot for each document.

        ValueIterator Xapian::Database::valuestream_begin(Xapian::valueno
        slot) const 
        """
        return _xapian.Database_valuestream_begin(self, *args)

    def valuestream_end(self, *args):
        """
        Return end iterator corresponding to valuestream_begin().

        ValueIteratorEnd_ Xapian::Database::valuestream_end(Xapian::valueno)
        const 
        """
        return _xapian.Database_valuestream_end(self, *args)

    def get_doclength(self, *args):
        """
        Get the length of a document.

        Xapian::termcount Xapian::Database::get_doclength(Xapian::docid did)
        const 
        """
        return _xapian.Database_get_doclength(self, *args)

    def keep_alive(self):
        """
        Send a "keep-alive" to remote databases to stop them timing out.

        void Xapian::Database::keep_alive()

        Has no effect on non-remote databases. 
        """
        return _xapian.Database_keep_alive(self)

    def get_document(self, *args):
        """
        Get a document from the database, given its document id.

        Xapian::Document Xapian::Database::get_document(Xapian::docid did)
        const

        This method returns a Xapian::Document object which provides the
        information about a document.

        Parameters:
        -----------

        did:  The document id of the document to retrieve.

        A Xapian::Document object containing the document data

        Parameters:
        -----------

        Xapian::DocNotFoundError:  The document specified could not be found
        in the database.

        Xapian::InvalidArgumentError:  did was 0, which is not a valid
        document id. 
        """
        return _xapian.Database_get_document(self, *args)

    def get_spelling_suggestion(self, *args):
        """
        Suggest a spelling correction.

        std::string Xapian::Database::get_spelling_suggestion(const
        std::string &word, unsigned max_edit_distance=2) const

        Parameters:
        -----------

        word:  The potentially misspelled word.

        max_edit_distance:  Only consider words which are at most
        max_edit_distance edits from word. An edit is a character insertion,
        deletion, or the transposition of two adjacent characters (default is
        2). 
        """
        return _xapian.Database_get_spelling_suggestion(self, *args)

    def spellings_begin(self):
        """
        An iterator which returns all the spelling correction targets.

        Xapian::TermIterator Xapian::Database::spellings_begin() const

        This returns all the words which are considered as targets for the
        spelling correction algorithm. The frequency of each word is available
        as the term frequency of each entry in the returned iterator. 
        """
        return _xapian.Database_spellings_begin(self)

    def spellings_end(self):
        """
        Corresponding end iterator to spellings_begin().

        Xapian::TermIterator Xapian::Database::spellings_end() const 
        """
        return _xapian.Database_spellings_end(self)

    def synonyms_begin(self, *args):
        """
        An iterator which returns all the synonyms for a given term.

        Xapian::TermIterator Xapian::Database::synonyms_begin(const
        std::string &term) const

        Parameters:
        -----------

        term:  The term to return synonyms for. 
        """
        return _xapian.Database_synonyms_begin(self, *args)

    def synonyms_end(self, *args):
        """
        Corresponding end iterator to synonyms_begin(term).

        Xapian::TermIterator Xapian::Database::synonyms_end(const std::string
        &) const 
        """
        return _xapian.Database_synonyms_end(self, *args)

    def synonym_keys_begin(self, prefix=""):
        """
        An iterator which returns all terms which have synonyms.

        Xapian::TermIterator Xapian::Database::synonym_keys_begin(const
        std::string &prefix=std::string()) const

        Parameters:
        -----------

        prefix:  If non-empty, only terms with this prefix are returned. 
        """
        return _xapian.Database_synonym_keys_begin(self, prefix)

    def synonym_keys_end(self, prefix=""):
        """
        Corresponding end iterator to synonym_keys_begin(prefix).

        Xapian::TermIterator Xapian::Database::synonym_keys_end(const
        std::string &=std::string()) const 
        """
        return _xapian.Database_synonym_keys_end(self, prefix)

    def get_metadata(self, *args):
        """
        Get the user-specified metadata associated with a given key.

        std::string Xapian::Database::get_metadata(const std::string &key)
        const

        User-specified metadata allows you to store arbitrary information in
        the form of (key,tag) pairs. See  WritableDatabase::set_metadata() for
        more information.

        When invoked on a Xapian::Database object representing multiple
        databases, currently only the metadata for the first is considered but
        this behaviour may change in the future.

        If there is no piece of metadata associated with the specified key, an
        empty string is returned (this applies even for backends which don't
        support metadata).

        Empty keys are not valid, and specifying one will cause an exception.

        Parameters:
        -----------

        key:  The key of the metadata item to access.

        The retrieved metadata item's value.

        Parameters:
        -----------

        Xapian::InvalidArgumentError:  will be thrown if the key supplied is
        empty. 
        """
        return _xapian.Database_get_metadata(self, *args)

    def _metadata_keys_begin(self, prefix=""):
        """
        An iterator which returns all user-specified metadata keys.

        Xapian::TermIterator Xapian::Database::metadata_keys_begin(const
        std::string &prefix=std::string()) const

        When invoked on a Xapian::Database object representing multiple
        databases, currently only the metadata for the first is considered but
        this behaviour may change in the future.

        If the backend doesn't support metadata, then this method returns an
        iterator which compares equal to that returned by metadata_keys_end().

        Parameters:
        -----------

        prefix:  If non-empty, only keys with this prefix are returned.

        Parameters:
        -----------

        Xapian::UnimplementedError:  will be thrown if the backend implements
        user-specified metadata, but doesn't implement iterating its keys
        (currently this happens for the InMemory backend). 
        """
        return _xapian.Database__metadata_keys_begin(self, prefix)

    def _metadata_keys_end(self, prefix=""):
        """
        Corresponding end iterator to metadata_keys_begin().

        Xapian::TermIterator Xapian::Database::metadata_keys_end(const
        std::string &=std::string()) const 
        """
        return _xapian.Database__metadata_keys_end(self, prefix)

    def get_uuid(self):
        """
        Get a UUID for the database.

        std::string Xapian::Database::get_uuid() const

        The UUID will persist for the lifetime of the database.

        Replicas (eg, made with the replication protocol, or by copying all
        the database files) will have the same UUID. However, copies (made
        with copydatabase, or xapian-compact) will have different UUIDs.

        If the backend does not support UUIDs or this database has no
        subdatabases, the UUID will be empty.

        If this database has multiple sub-databases, the UUID string will
        contain the UUIDs of all the sub-databases. 
        """
        return _xapian.Database_get_uuid(self)

    def has_positions(self):
        """
        Does this database have any positional information?

        bool Xapian::Database::has_positions() const 
        """
        return _xapian.Database_has_positions(self)

Database.add_database = new_instancemethod(_xapian.Database_add_database,None,Database)
Database.reopen = new_instancemethod(_xapian.Database_reopen,None,Database)
Database.close = new_instancemethod(_xapian.Database_close,None,Database)
Database.__str__ = new_instancemethod(_xapian.Database___str__,None,Database)
Database.postlist_begin = new_instancemethod(_xapian.Database_postlist_begin,None,Database)
Database.postlist_end = new_instancemethod(_xapian.Database_postlist_end,None,Database)
Database.termlist_begin = new_instancemethod(_xapian.Database_termlist_begin,None,Database)
Database.termlist_end = new_instancemethod(_xapian.Database_termlist_end,None,Database)
Database.positionlist_begin = new_instancemethod(_xapian.Database_positionlist_begin,None,Database)
Database.positionlist_end = new_instancemethod(_xapian.Database_positionlist_end,None,Database)
Database.allterms_begin = new_instancemethod(_xapian.Database_allterms_begin,None,Database)
Database.allterms_end = new_instancemethod(_xapian.Database_allterms_end,None,Database)
Database.get_doccount = new_instancemethod(_xapian.Database_get_doccount,None,Database)
Database.get_lastdocid = new_instancemethod(_xapian.Database_get_lastdocid,None,Database)
Database.get_avlength = new_instancemethod(_xapian.Database_get_avlength,None,Database)
Database.get_termfreq = new_instancemethod(_xapian.Database_get_termfreq,None,Database)
Database.term_exists = new_instancemethod(_xapian.Database_term_exists,None,Database)
Database.get_collection_freq = new_instancemethod(_xapian.Database_get_collection_freq,None,Database)
Database.get_value_freq = new_instancemethod(_xapian.Database_get_value_freq,None,Database)
Database.get_value_lower_bound = new_instancemethod(_xapian.Database_get_value_lower_bound,None,Database)
Database.get_value_upper_bound = new_instancemethod(_xapian.Database_get_value_upper_bound,None,Database)
Database.get_doclength_lower_bound = new_instancemethod(_xapian.Database_get_doclength_lower_bound,None,Database)
Database.get_doclength_upper_bound = new_instancemethod(_xapian.Database_get_doclength_upper_bound,None,Database)
Database.get_wdf_upper_bound = new_instancemethod(_xapian.Database_get_wdf_upper_bound,None,Database)
Database.valuestream_begin = new_instancemethod(_xapian.Database_valuestream_begin,None,Database)
Database.valuestream_end = new_instancemethod(_xapian.Database_valuestream_end,None,Database)
Database.get_doclength = new_instancemethod(_xapian.Database_get_doclength,None,Database)
Database.keep_alive = new_instancemethod(_xapian.Database_keep_alive,None,Database)
Database.get_document = new_instancemethod(_xapian.Database_get_document,None,Database)
Database.get_spelling_suggestion = new_instancemethod(_xapian.Database_get_spelling_suggestion,None,Database)
Database.spellings_begin = new_instancemethod(_xapian.Database_spellings_begin,None,Database)
Database.spellings_end = new_instancemethod(_xapian.Database_spellings_end,None,Database)
Database.synonyms_begin = new_instancemethod(_xapian.Database_synonyms_begin,None,Database)
Database.synonyms_end = new_instancemethod(_xapian.Database_synonyms_end,None,Database)
Database.synonym_keys_begin = new_instancemethod(_xapian.Database_synonym_keys_begin,None,Database)
Database.synonym_keys_end = new_instancemethod(_xapian.Database_synonym_keys_end,None,Database)
Database.get_metadata = new_instancemethod(_xapian.Database_get_metadata,None,Database)
Database._metadata_keys_begin = new_instancemethod(_xapian.Database__metadata_keys_begin,None,Database)
Database._metadata_keys_end = new_instancemethod(_xapian.Database__metadata_keys_end,None,Database)
Database.get_uuid = new_instancemethod(_xapian.Database_get_uuid,None,Database)
Database.has_positions = new_instancemethod(_xapian.Database_has_positions,None,Database)
Database_swigregister = _xapian.Database_swigregister
Database_swigregister(Database)

class WritableDatabase(Database):
    """
    This class provides read/write access to a database. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    __swig_destroy__ = _xapian.delete_WritableDatabase
    def __init__(self, *args): 
        """
        Copying is allowed.

        Xapian::WritableDatabase::WritableDatabase(const WritableDatabase
        &other)

        The internals are reference counted, so copying is cheap.

        Parameters:
        -----------

        other:  The object to copy. 
        """
        _xapian.WritableDatabase_swiginit(self,_xapian.new_WritableDatabase(*args))
    def commit(self):
        """
        Commit any pending modifications made to the database.

        void Xapian::WritableDatabase::commit()

        For efficiency reasons, when performing multiple updates to a database
        it is best (indeed, almost essential) to make as many modifications as
        memory will permit in a single pass through the database. To ensure
        this, Xapian batches up modifications.

        This method may be called at any time to commit any pending
        modifications to the database.

        If any of the modifications fail, an exception will be thrown and the
        database will be left in a state in which each separate addition,
        replacement or deletion operation has either been fully performed or
        not performed at all: it is then up to the application to work out
        which operations need to be repeated.

        It's not valid to call commit() within a transaction.

        Beware of calling commit() too frequently: this will make indexing
        take much longer.

        Note that commit() need not be called explicitly: it will be called
        automatically when the database is closed, or when a sufficient number
        of modifications have been made. By default, this is every 10000
        documents added, deleted, or modified. This value is rather
        conservative, and if you have a machine with plenty of memory, you can
        improve indexing throughput dramatically by setting
        XAPIAN_FLUSH_THRESHOLD in the environment to a larger value.

        This method was new in Xapian 1.1.0 - in earlier versions it was
        called flush().

        Parameters:
        -----------

        Xapian::DatabaseError:  will be thrown if a problem occurs while
        modifying the database.

        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
        corrupt state. 
        """
        return _xapian.WritableDatabase_commit(self)

    def flush(self):
        """
        Pre-1.1.0 name for commit().

        void Xapian::WritableDatabase::flush()

        Use commit() instead in new code. This alias may be deprecated in the
        future. 
        """
        return _xapian.WritableDatabase_flush(self)

    def begin_transaction(self, flushed=True):
        """
        Begin a transaction.

        void Xapian::WritableDatabase::begin_transaction(bool flushed=true)

        In Xapian a transaction is a group of modifications to the database
        which are linked such that either all will be applied simultaneously
        or none will be applied at all. Even in the case of a power failure,
        this characteristic should be preserved (as long as the filesystem
        isn't corrupted, etc).

        A transaction is started with begin_transaction() and can either be
        committed by calling commit_transaction() or aborted by calling
        cancel_transaction().

        By default, a transaction implicitly calls commit() before and after
        so that the modifications stand and fall without affecting
        modifications before or after.

        The downside of these implicit calls to commit() is that small
        transactions can harm indexing performance in the same way that
        explicitly calling commit() frequently can.

        If you're applying atomic groups of changes and only wish to ensure
        that each group is either applied or not applied, then you can prevent
        the automatic commit() before and after the transaction by starting
        the transaction with begin_transaction(false). However, if
        cancel_transaction is called (or if commit_transaction isn't called
        before the WritableDatabase object is destroyed) then any changes
        which were pending before the transaction began will also be
        discarded.

        Transactions aren't currently supported by the InMemory backend.

        Parameters:
        -----------

        flushed:  Is this a flushed transaction? By default transactions are
        "flushed", which means that committing a transaction will ensure
        those changes are permanently written to the database. By contrast,
        unflushed transactions only ensure that changes within the transaction
        are either all applied or all aren't.

        Parameters:
        -----------

        Xapian::UnimplementedError:  will be thrown if transactions are not
        available for this database type.

        Xapian::InvalidOperationError:  will be thrown if this is called at an
        invalid time, such as when a transaction is already in progress. 
        """
        return _xapian.WritableDatabase_begin_transaction(self, flushed)

    def commit_transaction(self):
        """
        Complete the transaction currently in progress.

        void Xapian::WritableDatabase::commit_transaction()

        If this method completes successfully and this is a flushed
        transaction, all the database modifications made during the
        transaction will have been committed to the database.

        If an error occurs, an exception will be thrown, and none of the
        modifications made to the database during the transaction will have
        been applied to the database.

        In all cases the transaction will no longer be in progress.

        Parameters:
        -----------

        Xapian::DatabaseError:  will be thrown if a problem occurs while
        modifying the database.

        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
        corrupt state.

        Xapian::InvalidOperationError:  will be thrown if a transaction is not
        currently in progress.

        Xapian::UnimplementedError:  will be thrown if transactions are not
        available for this database type. 
        """
        return _xapian.WritableDatabase_commit_transaction(self)

    def cancel_transaction(self):
        """
        Abort the transaction currently in progress, discarding the pending
        modifications made to the database.

        void Xapian::WritableDatabase::cancel_transaction()

        If an error occurs in this method, an exception will be thrown, but
        the transaction will be cancelled anyway.

        Parameters:
        -----------

        Xapian::DatabaseError:  will be thrown if a problem occurs while
        modifying the database.

        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
        corrupt state.

        Xapian::InvalidOperationError:  will be thrown if a transaction is not
        currently in progress.

        Xapian::UnimplementedError:  will be thrown if transactions are not
        available for this database type. 
        """
        return _xapian.WritableDatabase_cancel_transaction(self)

    def add_document(self, *args):
        """
        Add a new document to the database.

        Xapian::docid Xapian::WritableDatabase::add_document(const
        Xapian::Document &document)

        This method adds the specified document to the database, returning a
        newly allocated document ID. Automatically allocated document IDs come
        from a per-database monotonically increasing counter, so IDs from
        deleted documents won't be reused.

        If you want to specify the document ID to be used, you should call
        replace_document() instead.

        Note that changes to the database won't be immediately committed to
        disk; see commit() for more details.

        As with all database modification operations, the effect is atomic:
        the document will either be fully added, or the document fails to be
        added and an exception is thrown (possibly at a later time when
        commit() is called or the database is closed).

        Parameters:
        -----------

        document:  The new document to be added.

        The document ID of the newly added document.

        Parameters:
        -----------

        Xapian::DatabaseError:  will be thrown if a problem occurs while
        writing to the database.

        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
        corrupt state. 
        """
        return _xapian.WritableDatabase_add_document(self, *args)

    def delete_document(self, *args):
        """
        Delete any documents indexed by a term from the database.

        void Xapian::WritableDatabase::delete_document(const std::string
        &unique_term)

        This method removes any documents indexed by the specified term from
        the database.

        A major use is for convenience when UIDs from another system are
        mapped to terms in Xapian, although this method has other uses (for
        example, you could add a "deletion date" term to documents at index
        time and use this method to delete all documents due for deletion on a
        particular date).

        Parameters:
        -----------

        unique_term:  The term to remove references to.

        Parameters:
        -----------

        Xapian::DatabaseError:  will be thrown if a problem occurs while
        writing to the database.

        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
        corrupt state. 
        """
        return _xapian.WritableDatabase_delete_document(self, *args)

    def replace_document(self, *args):
        """
        Replace any documents matching a term.

        Xapian::docid Xapian::WritableDatabase::replace_document(const
        std::string &unique_term, const Xapian::Document &document)

        This method replaces any documents indexed by the specified term with
        the specified document. If any documents are indexed by the term, the
        lowest document ID will be used for the document, otherwise a new
        document ID will be generated as for add_document.

        One common use is to allow UIDs from another system to easily be
        mapped to terms in Xapian. Note that this method doesn't automatically
        add unique_term as a term, so you'll need to call
        document.add_term(unique_term) first when using replace_document() in
        this way.

        Note that changes to the database won't be immediately committed to
        disk; see commit() for more details.

        As with all database modification operations, the effect is atomic:
        the document(s) will either be fully replaced, or the document(s) fail
        to be replaced and an exception is thrown (possibly at a later time
        when commit() is called or the database is closed).

        Parameters:
        -----------

        unique_term:  The "unique" term.

        document:  The new document.

        The document ID that document was given.

        Parameters:
        -----------

        Xapian::DatabaseError:  will be thrown if a problem occurs while
        writing to the database.

        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
        corrupt state. 
        """
        return _xapian.WritableDatabase_replace_document(self, *args)

    def add_spelling(self, *args):
        """
        Add a word to the spelling dictionary.

        void Xapian::WritableDatabase::add_spelling(const std::string &word,
        Xapian::termcount freqinc=1) const

        If the word is already present, its frequency is increased.

        Parameters:
        -----------

        word:  The word to add.

        freqinc:  How much to increase its frequency by (default 1). 
        """
        return _xapian.WritableDatabase_add_spelling(self, *args)

    def remove_spelling(self, *args):
        """
        Remove a word from the spelling dictionary.

        void Xapian::WritableDatabase::remove_spelling(const std::string
        &word, Xapian::termcount freqdec=1) const

        The word's frequency is decreased, and if would become zero or less
        then the word is removed completely.

        Parameters:
        -----------

        word:  The word to remove.

        freqdec:  How much to decrease its frequency by (default 1). 
        """
        return _xapian.WritableDatabase_remove_spelling(self, *args)

    def add_synonym(self, *args):
        """
        Add a synonym for a term.

        void Xapian::WritableDatabase::add_synonym(const std::string &term,
        const std::string &synonym) const

        Parameters:
        -----------

        term:  The term to add a synonym for.

        synonym:  The synonym to add. If this is already a synonym for term,
        then no action is taken. 
        """
        return _xapian.WritableDatabase_add_synonym(self, *args)

    def remove_synonym(self, *args):
        """
        Remove a synonym for a term.

        void Xapian::WritableDatabase::remove_synonym(const std::string &term,
        const std::string &synonym) const

        Parameters:
        -----------

        term:  The term to remove a synonym for.

        synonym:  The synonym to remove. If this isn't currently a synonym for
        term, then no action is taken. 
        """
        return _xapian.WritableDatabase_remove_synonym(self, *args)

    def clear_synonyms(self, *args):
        """
        Remove all synonyms for a term.

        void Xapian::WritableDatabase::clear_synonyms(const std::string &term)
        const

        Parameters:
        -----------

        term:  The term to remove all synonyms for. If the term has no
        synonyms, no action is taken. 
        """
        return _xapian.WritableDatabase_clear_synonyms(self, *args)

    def set_metadata(self, *args):
        """
        Set the user-specified metadata associated with a given key.

        void Xapian::WritableDatabase::set_metadata(const std::string &key,
        const std::string &value)

        This method sets the metadata value associated with a given key. If
        there is already a metadata value stored in the database with the same
        key, the old value is replaced. If you want to delete an existing item
        of metadata, just set its value to the empty string.

        User-specified metadata allows you to store arbitrary information in
        the form of (key,tag) pairs.

        There's no hard limit on the number of metadata items, or the size of
        the metadata values. Metadata keys have a limited length, which
        depends on the backend. We recommend limiting them to 200 bytes. Empty
        keys are not valid, and specifying one will cause an exception.

        Metadata modifications are committed to disk in the same way as
        modifications to the documents in the database are: i.e.,
        modifications are atomic, and won't be committed to disk immediately
        (see commit() for more details). This allows metadata to be used to
        link databases with versioned external resources by storing the
        appropriate version number in a metadata item.

        You can also use the metadata to store arbitrary extra information
        associated with terms, documents, or postings by encoding the termname
        and/or document id into the metadata key.

        Parameters:
        -----------

        key:  The key of the metadata item to set.

        value:  The value of the metadata item to set.

        Parameters:
        -----------

        Xapian::DatabaseError:  will be thrown if a problem occurs while
        writing to the database.

        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
        corrupt state.

        Xapian::InvalidArgumentError:  will be thrown if the key supplied is
        empty.

        Xapian::UnimplementedError:  will be thrown if the database backend in
        use doesn't support user- specified metadata. 
        """
        return _xapian.WritableDatabase_set_metadata(self, *args)

    def __str__(self):
        """
        Return a string describing this object.

        std::string Xapian::WritableDatabase::get_description() const 
        """
        return _xapian.WritableDatabase___str__(self)

WritableDatabase.commit = new_instancemethod(_xapian.WritableDatabase_commit,None,WritableDatabase)
WritableDatabase.flush = new_instancemethod(_xapian.WritableDatabase_flush,None,WritableDatabase)
WritableDatabase.begin_transaction = new_instancemethod(_xapian.WritableDatabase_begin_transaction,None,WritableDatabase)
WritableDatabase.commit_transaction = new_instancemethod(_xapian.WritableDatabase_commit_transaction,None,WritableDatabase)
WritableDatabase.cancel_transaction = new_instancemethod(_xapian.WritableDatabase_cancel_transaction,None,WritableDatabase)
WritableDatabase.add_document = new_instancemethod(_xapian.WritableDatabase_add_document,None,WritableDatabase)
WritableDatabase.delete_document = new_instancemethod(_xapian.WritableDatabase_delete_document,None,WritableDatabase)
WritableDatabase.replace_document = new_instancemethod(_xapian.WritableDatabase_replace_document,None,WritableDatabase)
WritableDatabase.add_spelling = new_instancemethod(_xapian.WritableDatabase_add_spelling,None,WritableDatabase)
WritableDatabase.remove_spelling = new_instancemethod(_xapian.WritableDatabase_remove_spelling,None,WritableDatabase)
WritableDatabase.add_synonym = new_instancemethod(_xapian.WritableDatabase_add_synonym,None,WritableDatabase)
WritableDatabase.remove_synonym = new_instancemethod(_xapian.WritableDatabase_remove_synonym,None,WritableDatabase)
WritableDatabase.clear_synonyms = new_instancemethod(_xapian.WritableDatabase_clear_synonyms,None,WritableDatabase)
WritableDatabase.set_metadata = new_instancemethod(_xapian.WritableDatabase_set_metadata,None,WritableDatabase)
WritableDatabase.__str__ = new_instancemethod(_xapian.WritableDatabase___str__,None,WritableDatabase)
WritableDatabase_swigregister = _xapian.WritableDatabase_swigregister
WritableDatabase_swigregister(WritableDatabase)

DB_CREATE_OR_OPEN = _xapian.DB_CREATE_OR_OPEN
DB_CREATE = _xapian.DB_CREATE
DB_CREATE_OR_OVERWRITE = _xapian.DB_CREATE_OR_OVERWRITE
DB_OPEN = _xapian.DB_OPEN

def open_stub(*args):
  """
    Construct a WritableDatabase object for a stub database file.

    WritableDatabase Xapian::Auto::open_stub(const std::string &file, int
    action)

    The stub database file must contain serialised parameters for exactly
    one database.

    Parameters:
    -----------

    file:  pathname of the stub database file.

    action:  determines handling of existing/non-existing database:
    Xapian::DB_CREATE fail if database already exist, otherwise create new
    database.

    Xapian::DB_CREATE_OR_OPEN open existing database, or create new
    database if none exists.

    Xapian::DB_CREATE_OR_OVERWRITE overwrite existing database, or create
    new database if none exists.

    Xapian::DB_OPEN open existing database, failing if none exists. 
    """
  return _xapian.open_stub(*args)

def brass_open(*args):
  """
    Construct a Database object for update access to a Brass database.

    WritableDatabase Xapian::Brass::open(const std::string &dir, int
    action, int block_size=8192)

    Parameters:
    -----------

    dir:  pathname of the directory containing the database.

    action:  determines handling of existing/non-existing database:
    Xapian::DB_CREATE fail if database already exist, otherwise create new
    database.

    Xapian::DB_CREATE_OR_OPEN open existing database, or create new
    database if none exists.

    Xapian::DB_CREATE_OR_OVERWRITE overwrite existing database, or create
    new database if none exists.

    Xapian::DB_OPEN open existing database, failing if none exists.

    block_size:  the Btree blocksize to use (in bytes), which must be a
    power of two between 2048 and 65536 (inclusive). The default (also
    used if an invalid value if passed) is 8192 bytes. This parameter is
    ignored when opening an existing database. 
    """
  return _xapian.brass_open(*args)

def chert_open(*args):
  """
    Construct a Database object for update access to a Chert database.

    WritableDatabase Xapian::Chert::open(const std::string &dir, int
    action, int block_size=8192)

    Parameters:
    -----------

    dir:  pathname of the directory containing the database.

    action:  determines handling of existing/non-existing database:
    Xapian::DB_CREATE fail if database already exist, otherwise create new
    database.

    Xapian::DB_CREATE_OR_OPEN open existing database, or create new
    database if none exists.

    Xapian::DB_CREATE_OR_OVERWRITE overwrite existing database, or create
    new database if none exists.

    Xapian::DB_OPEN open existing database, failing if none exists.

    block_size:  the Btree blocksize to use (in bytes), which must be a
    power of two between 2048 and 65536 (inclusive). The default (also
    used if an invalid value if passed) is 8192 bytes. This parameter is
    ignored when opening an existing database. 
    """
  return _xapian.chert_open(*args)

def flint_open(*args):
  """
    Construct a Database object for update access to a Flint database.

    WritableDatabase Xapian::Flint::open(const std::string &dir, int
    action, int block_size=8192)

    Parameters:
    -----------

    dir:  pathname of the directory containing the database.

    action:  determines handling of existing/non-existing database:
    Xapian::DB_CREATE fail if database already exist, otherwise create new
    database.

    Xapian::DB_CREATE_OR_OPEN open existing database, or create new
    database if none exists.

    Xapian::DB_CREATE_OR_OVERWRITE overwrite existing database, or create
    new database if none exists.

    Xapian::DB_OPEN open existing database, failing if none exists.

    block_size:  the Btree blocksize to use (in bytes), which must be a
    power of two between 2048 and 65536 (inclusive). The default (also
    used if an invalid value if passed) is 8192 bytes. This parameter is
    ignored when opening an existing database. 
    """
  return _xapian.flint_open(*args)

def inmemory_open():
  """
    Construct a WritableDatabase object for a new, empty InMemory
    database.

    WritableDatabase Xapian::InMemory::open()

    Only a writable InMemory database can be created, since a read-only
    one would always remain empty. 
    """
  return _xapian.inmemory_open()

def remote_open(*args):
  """
    Construct a Database object for read-only access to a remote database
    accessed via a program.

    Database Xapian::Remote::open(const std::string &program, const
    std::string &args, Xapian::timeout timeout=10000)

    Access to the remote database is done by running an external program
    and communicating with it on stdin/stdout.

    Parameters:
    -----------

    program:  the external program to run.

    args:  space-separated list of arguments to pass to program.

    timeout:  timeout in milliseconds. If this timeout is exceeded for any
    individual operation on the remote database then
    Xapian::NetworkTimeoutError is thrown. A timeout of 0 means don't
    timeout. (Default is 10000ms, which is 10 seconds). 
    """
  return _xapian.remote_open(*args)

def remote_open_writable(*args):
  """
    Construct a WritableDatabase object for update access to a remote
    database accessed via a program.

    WritableDatabase Xapian::Remote::open_writable(const std::string
    &program, const std::string &args, Xapian::timeout timeout=0)

    Access to the remote database is done by running an external program
    and communicating with it on stdin/stdout.

    Parameters:
    -----------

    program:  the external program to run.

    args:  space-separated list of arguments to pass to program.

    timeout:  timeout in milliseconds. If this timeout is exceeded for any
    individual operation on the remote database then
    Xapian::NetworkTimeoutError is thrown. (Default is 0, which means
    don't timeout). 
    """
  return _xapian.remote_open_writable(*args)
class Query(object):
    """
    Class representing a query.

    Queries are represented as a tree of objects. 
    """
    thisown = _swig_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
    __swig_destroy__ = _xapian.delete_Query
    def get_length(self):
        """
        Get the length of the query, used by some ranking formulae.

        Xapian::termcount Xapian::Query::get_length() const

        This value is calculated automatically - if you want to override it
        you can pass a different value to Enquire::set_query(). 
        """
        return _xapian.Query_get_length(self)

    def get_terms_begin(self):
        """
        Return a Xapian::TermIterator returning all the terms in the query, in
        order of termpos.

        TermIterator Xapian::Query::get_terms_begin() const

        If multiple terms have the same term position, their order is
        unspecified. Duplicates (same term and termpos) will be removed. 
        """
        return _xapian.Query_get_terms_begin(self)

    def get_terms_end(self):
        """
        Return a Xapian::TermIterator to the end of the list of terms in the
        query.

        TermIterator Xapian::Query::get_terms_end() const 
        """
        return _xapian.Query_get_terms_end(self)

    def empty(self):
        """
        Test if the query is empty (i.e.

        bool Xapian::Query::empty() const

        was constructed using the default ctor or with an empty iterator
        ctor). 
        """
        return _xapian.Query_empty(self)

    def serialise(self):
        """
        Serialise query into a string.

        std::string Xapian::Query::serialise() const

        The query representation may change between Xapian releases: even
        between minor versions. However, it is guaranteed not to change unless
        the remote database protocol has also changed between releases. 
        """
        return _xapian.Query_serialise(self)

    unserialise = staticmethod(_xapian.Query_unserialise)
    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 an external source query.

        Xapian::Query::Query(Xapian::PostingSource *external_source)

        An attempt to clone the posting source will be made immediately, so if
        the posting source supports clone(), the source supplied may be safely
        deallocated after this call. If the source does not support clone(),
        the caller must ensure that the posting source remains valid until the
        Query is deallocated.

        Parameters:
        -----------

        external_source:  The source to use in the query. 
        """
        _xapian.Query_swiginit(self,_xapian.new_Query(*args))
Query.get_length = new_instancemethod(_xapian.Query_get_length,None,Query)
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.empty = new_instancemethod(_xapian.Query_empty,None,Query)
Query.serialise = new_instancemethod(_xapian.Query_serialise,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

class Stopper(object):
    """
    Base class for stop-word decision functor. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    __swig_destroy__ = _xapian.delete_Stopper
    def __str__(self):
        """
        Return a string describing this object.

        virtual std::string Xapian::Stopper::get_description() const 
        """
        return _xapian.Stopper___str__(self)

    def __init__(self): 
        if self.__class__ == Stopper:
            _self = None
        else:
            _self = self
        _xapian.Stopper_swiginit(self,_xapian.new_Stopper(_self, ))
    def __disown__(self):
        self.this.disown()
        _xapian.disown_Stopper(self)
        return weakref_proxy(self)
Stopper.__call__ = new_instancemethod(_xapian.Stopper___call__,None,Stopper)
Stopper.__str__ = new_instancemethod(_xapian.Stopper___str__,None,Stopper)
Stopper_swigregister = _xapian.Stopper_swigregister
Stopper_swigregister(Stopper)

class SimpleStopper(Stopper):
    """
    Simple implementation of Stopper class - this will suit most users. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self): 
        """
        Initialise from a pair of iterators.

        Xapian::SimpleStopper::SimpleStopper(Iterator begin, Iterator end)

        Xapian includes stop list files for many languages. You can initialise
        from a file like that: 
        """
        _xapian.SimpleStopper_swiginit(self,_xapian.new_SimpleStopper())
    def add(self, *args):
        """
        Add a single stop word.

        void Xapian::SimpleStopper::add(const std::string &word) 
        """
        return _xapian.SimpleStopper_add(self, *args)

    __swig_destroy__ = _xapian.delete_SimpleStopper
SimpleStopper.add = new_instancemethod(_xapian.SimpleStopper_add,None,SimpleStopper)
SimpleStopper_swigregister = _xapian.SimpleStopper_swigregister
SimpleStopper_swigregister(SimpleStopper)

class ValueRangeProcessor(object):
    """
    Base class for value range processors. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    __swig_destroy__ = _xapian.delete_ValueRangeProcessor
    def __init__(self): 
        if self.__class__ == ValueRangeProcessor:
            _self = None
        else:
            _self = self
        _xapian.ValueRangeProcessor_swiginit(self,_xapian.new_ValueRangeProcessor(_self, ))
    def __disown__(self):
        self.this.disown()
        _xapian.disown_ValueRangeProcessor(self)
        return weakref_proxy(self)
ValueRangeProcessor.__call__ = new_instancemethod(_xapian.ValueRangeProcessor___call__,None,ValueRangeProcessor)
ValueRangeProcessor_swigregister = _xapian.ValueRangeProcessor_swigregister
ValueRangeProcessor_swigregister(ValueRangeProcessor)

class StringValueRangeProcessor(ValueRangeProcessor):
    """
    Handle a string range.

    The end points can be any strings. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self, *args): 
        """
        Constructor.

        Xapian::StringValueRangeProcessor::StringValueRangeProcessor(Xapian::valueno
        slot_, const std::string &str_, bool prefix_=true)

        Parameters:
        -----------

        slot_:  The value number to return from operator().

        str_:  A string to look for to recognise values as belonging to this
        range.

        prefix_:  Flag specifying whether to check for str_ as a prefix or a
        suffix. 
        """
        _xapian.StringValueRangeProcessor_swiginit(self,_xapian.new_StringValueRangeProcessor(*args))
    __swig_destroy__ = _xapian.delete_StringValueRangeProcessor
StringValueRangeProcessor_swigregister = _xapian.StringValueRangeProcessor_swigregister
StringValueRangeProcessor_swigregister(StringValueRangeProcessor)

class DateValueRangeProcessor(StringValueRangeProcessor):
    """
    Handle a date range.

    Begin and end must be dates in a recognised format. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self, *args): 
        """
        Constructor.

        Xapian::DateValueRangeProcessor::DateValueRangeProcessor(Xapian::valueno
        slot_, const char *str_, bool prefix_=true, bool prefer_mdy_=false,
        int epoch_year_=1970)

        This is like the previous version, but with const char * instead of
        std::string - we need this overload as otherwise
        DateValueRangeProcessor(1, "date:") quietly interprets the second
        argument as a boolean in preference to std::string. If you want to be
        compatible with 1.2.12 and earlier, then explicitly convert to
        std::string, i.e.: DateValueRangeProcessor(1, std::string("date:"))

        Parameters:
        -----------

        slot_:  The value number to return from operator().

        str_:  A string to look for to recognise values as belonging to this
        date range.

        prefix_:  Whether to look for the string at the start or end of the
        values. If true, the string is a prefix; if false, the string is a
        suffix (default: true).

        prefer_mdy_:  Should ambiguous dates be interpreted as month/day/year
        rather than day/month/year? (default: false)

        epoch_year_:  Year to use as the epoch for dates with 2 digit years
        (default: 1970, so 1/1/69 is 2069 while 1/1/70 is 1970).

        The string supplied in str_ is used by operator() to decide whether
        the pair of strings supplied to it constitute a valid range. If
        prefix_ is true, the first value in a range must begin with str_ (and
        the second value may optionally begin with str_); if prefix_ is false,
        the second value in a range must end with str_ (and the first value
        may optionally end with str_).

        If str_ is empty, the setting of prefix_ is irrelevant, and no special
        strings are required at the start or end of the strings defining the
        range.

        The remainder of both strings defining the endpoints must be valid
        dates.

        For example, if str_ is "created:" and prefix_ is true, and the
        range processor has been added to the queryparser, the queryparser
        will accept "created:1/1/2000..31/12/2001". 
        """
        _xapian.DateValueRangeProcessor_swiginit(self,_xapian.new_DateValueRangeProcessor(*args))
    __swig_destroy__ = _xapian.delete_DateValueRangeProcessor
DateValueRangeProcessor_swigregister = _xapian.DateValueRangeProcessor_swigregister
DateValueRangeProcessor_swigregister(DateValueRangeProcessor)

class NumberValueRangeProcessor(StringValueRangeProcessor):
    """
    Handle a number range.

    This class must be used on values which have been encoded using
    Xapian::sortable_serialise() which turns numbers into strings which
    will sort in the same order as the numbers (the same values can be
    used to implement a numeric sort). 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self, *args): 
        """
        Constructor.

        Xapian::NumberValueRangeProcessor::NumberValueRangeProcessor(Xapian::valueno
        slot_, const std::string &str_, bool prefix_=true)

        Parameters:
        -----------

        slot_:  The value number to return from operator().

        str_:  A string to look for to recognise values as belonging to this
        numeric range.

        prefix_:  Whether to look for the string at the start or end of the
        values. If true, the string is a prefix; if false, the string is a
        suffix (default: true).

        The string supplied in str_ is used by operator() to decide whether
        the pair of strings supplied to it constitute a valid range. If
        prefix_ is true, the first value in a range must begin with str_ (and
        the second value may optionally begin with str_); if prefix_ is false,
        the second value in a range must end with str_ (and the first value
        may optionally end with str_).

        If str_ is empty, the setting of prefix_ is irrelevant, and no special
        strings are required at the start or end of the strings defining the
        range.

        The remainder of both strings defining the endpoints must be valid
        floating point numbers. (FIXME: define format recognised).

        For example, if str_ is "$" and prefix_ is true, and the range
        processor has been added to the queryparser, the queryparser will
        accept "$10..50" or "$10..$50", but not "10..50" or "10..$50"
        as valid ranges. If str_ is "kg" and prefix_ is false, the
        queryparser will accept "10..50kg" or "10kg..50kg", but not
        "10..50" or "10kg..50" as valid ranges. 
        """
        _xapian.NumberValueRangeProcessor_swiginit(self,_xapian.new_NumberValueRangeProcessor(*args))
    __swig_destroy__ = _xapian.delete_NumberValueRangeProcessor
NumberValueRangeProcessor_swigregister = _xapian.NumberValueRangeProcessor_swigregister
NumberValueRangeProcessor_swigregister(NumberValueRangeProcessor)

class QueryParser(object):
    """
    Build a Xapian::Query object from a user query string. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    FLAG_BOOLEAN = _xapian.QueryParser_FLAG_BOOLEAN
    FLAG_PHRASE = _xapian.QueryParser_FLAG_PHRASE
    FLAG_LOVEHATE = _xapian.QueryParser_FLAG_LOVEHATE
    FLAG_BOOLEAN_ANY_CASE = _xapian.QueryParser_FLAG_BOOLEAN_ANY_CASE
    FLAG_WILDCARD = _xapian.QueryParser_FLAG_WILDCARD
    FLAG_PURE_NOT = _xapian.QueryParser_FLAG_PURE_NOT
    FLAG_PARTIAL = _xapian.QueryParser_FLAG_PARTIAL
    FLAG_SPELLING_CORRECTION = _xapian.QueryParser_FLAG_SPELLING_CORRECTION
    FLAG_SYNONYM = _xapian.QueryParser_FLAG_SYNONYM
    FLAG_AUTO_SYNONYMS = _xapian.QueryParser_FLAG_AUTO_SYNONYMS
    FLAG_AUTO_MULTIWORD_SYNONYMS = _xapian.QueryParser_FLAG_AUTO_MULTIWORD_SYNONYMS
    FLAG_CJK_NGRAM = _xapian.QueryParser_FLAG_CJK_NGRAM
    FLAG_DEFAULT = _xapian.QueryParser_FLAG_DEFAULT
    STEM_NONE = _xapian.QueryParser_STEM_NONE
    STEM_SOME = _xapian.QueryParser_STEM_SOME
    STEM_ALL = _xapian.QueryParser_STEM_ALL
    STEM_ALL_Z = _xapian.QueryParser_STEM_ALL_Z
    def __init__(self): 
        """
        Default constructor.

        Xapian::QueryParser::QueryParser() 
        """
        _xapian.QueryParser_swiginit(self,_xapian.new_QueryParser())
    __swig_destroy__ = _xapian.delete_QueryParser
    def set_stemmer(self, *args):
        """
        Set the stemmer.

        void Xapian::QueryParser::set_stemmer(const Xapian::Stem &stemmer)

        This sets the stemming algorithm which will be used by the query
        parser. Note that the stemming algorithm will only be used according
        to the stemming strategy set by set_stemming_strategy(), which
        defaults to STEM_NONE. Therefore, to use a stemming algorithm, you
        will also need to call set_stemming_strategy() with a value other than
        STEM_NONE.

        Parameters:
        -----------

        stemmer:  The Xapian::Stem object to set. 
        """
        return _xapian.QueryParser_set_stemmer(self, *args)

    def set_stemming_strategy(self, *args):
        """
        Set the stemming strategy.

        void Xapian::QueryParser::set_stemming_strategy(stem_strategy
        strategy)

        This controls how the query parser will apply the stemming algorithm.
        Note that the stemming algorithm is only applied to words in
        probabilistic fields - boolean filter terms are never stemmed.

        Parameters:
        -----------

        strategy:  The strategy to use - possible values are: STEM_NONE: Don't
        perform any stemming. (default in Xapian <= 1.3.0)

        STEM_SOME: Stem all terms except for those which start with a capital
        letter, or are followed by certain characters (currently: (/@<>=*[{"
        ), or are used with operators which need positional information.
        Stemmed terms are prefixed with 'Z'. (default in Xapian >= 1.3.1)

        STEM_ALL: Stem all terms (note: no 'Z' prefix is added).

        STEM_ALL_Z: Stem all terms (note: 'Z' prefix is added). (new in Xapian
        1.2.11 and 1.3.1) 
        """
        return _xapian.QueryParser_set_stemming_strategy(self, *args)

    def set_stopper(self, stop=None):
        """
        Set the stopper.

        void Xapian::QueryParser::set_stopper(const Stopper *stop=NULL)

        Parameters:
        -----------

        stop:  The Stopper object to set (default NULL, which means no
        stopwords). 
        """
        return _xapian.QueryParser_set_stopper(self, stop)

    def set_default_op(self, *args):
        """
        Set the default operator.

        void Xapian::QueryParser::set_default_op(Query::op default_op)

        Parameters:
        -----------

        default_op:  The operator to use to combine non-filter query items
        when no explicit operator is used.

        The most useful values for this are OP_OR (the default) and OP_AND.
        OP_NEAR and OP_PHRASE can also be useful.

        So for example, 'weather forecast' is parsed as if it were 'weather OR
        forecast' by default. 
        """
        return _xapian.QueryParser_set_default_op(self, *args)

    def get_default_op(self):
        """
        Get the current default operator.

        Query::op Xapian::QueryParser::get_default_op() const 
        """
        return _xapian.QueryParser_get_default_op(self)

    def set_database(self, *args):
        """
        Specify the database being searched.

        void Xapian::QueryParser::set_database(const Database &db)

        Parameters:
        -----------

        db:  The database to use for wildcard expansion (FLAG_WILDCARD and
        FLAG_PARTIAL), spelling correction (FLAG_SPELLING_CORRECTION), and
        synonyms (FLAG_SYNONYM, FLAG_AUTO_SYNONYMS, and
        FLAG_AUTO_MULTIWORD_SYNONYMS). 
        """
        return _xapian.QueryParser_set_database(self, *args)

    def set_max_wildcard_expansion(self, *args):
        """
        Specify the maximum expansion of a wildcard term.

        void Xapian::QueryParser::set_max_wildcard_expansion(Xapian::termcount
        limit)

        Note: you must also set FLAG_WILDCARD for wildcard expansion to
        happen.

        Parameters:
        -----------

        limit:  The maximum number of terms each wildcard in the query can
        expand to, or 0 for no limit (which is the default). 
        """
        return _xapian.QueryParser_set_max_wildcard_expansion(self, *args)

    def parse_query(self, *args):
        """
        Parse a query.

        Query Xapian::QueryParser::parse_query(const std::string
        &query_string, unsigned flags=FLAG_DEFAULT, const std::string
        &default_prefix=std::string())

        Parameters:
        -----------

        query_string:  A free-text query as entered by a user

        flags:  Zero or more Query::feature_flag specifying what features the
        QueryParser should support. Combine multiple values with bitwise-or
        (|) (default FLAG_DEFAULT).

        default_prefix:  The default term prefix to use (default none). For
        example, you can pass "A" when parsing an "Author" field.

        Parameters:
        -----------

        If:  the query string can't be parsed, then Xapian::QueryParserError
        is thrown. You can get an English error message to report to the user
        by catching it and calling get_msg() on the caught exception. The
        current possible values (in case you want to translate them) are:

        Unknown range operation

        parse error

        Syntax: <expression> AND <expression>

        Syntax: <expression> AND NOT <expression>

        Syntax: <expression> NOT <expression>

        Syntax: <expression> OR <expression>

        Syntax: <expression> XOR <expression> 
        """
        return _xapian.QueryParser_parse_query(self, *args)

    def add_prefix(self, *args):
        """
        Add a probabilistic term prefix.

        void Xapian::QueryParser::add_prefix(const std::string &field, const
        std::string &prefix)

        For example:

        This allows the user to search for author:Orwell which will be
        converted to a search for the term "Aorwell".

        Multiple fields can be mapped to the same prefix. For example, you can
        make title: and subject: aliases for each other.

        As of 1.0.4, you can call this method multiple times with the same
        value of field to allow a single field to be mapped to multiple
        prefixes. Multiple terms being generated for such a field, and
        combined with  Xapian::Query::OP_OR.

        If any prefixes are specified for the empty field name (i.e. you call
        this method with an empty string as the first parameter) these
        prefixes will be used for terms without a field specifier. If you do
        this and also specify the default_prefix parameter to  parse_query(),
        then the default_prefix parameter will override.

        If the prefix parameter is empty, then "field:word" will produce the
        term "word" (and this can be one of several prefixes for a
        particular field, or for terms without a field specifier).

        If you call  add_prefix() and  add_boolean_prefix() for the same value
        of field, a  Xapian::InvalidOperationError exception will be thrown.

        In 1.0.3 and earlier, subsequent calls to this method with the same
        value of field had no effect.

        Parameters:
        -----------

        field:  The user visible field name

        prefix:  The term prefix to map this to 
        """
        return _xapian.QueryParser_add_prefix(self, *args)

    def add_boolean_prefix(self, *args):
        """
        void
        Xapian::QueryParser::add_boolean_prefix(const std::string &field,
        const std::string &prefix) 
        """
        return _xapian.QueryParser_add_boolean_prefix(self, *args)

    def stoplist_begin(self):
        """
        Iterate over terms omitted from the query as stopwords.

        TermIterator Xapian::QueryParser::stoplist_begin() const 
        """
        return _xapian.QueryParser_stoplist_begin(self)

    def stoplist_end(self):
        """TermIterator Xapian::QueryParser::stoplist_end() const """
        return _xapian.QueryParser_stoplist_end(self)

    def unstem_begin(self, *args):
        """
        Iterate over unstemmed forms of the given (stemmed) term used in the
        query.

        TermIterator Xapian::QueryParser::unstem_begin(const std::string
        &term) const 
        """
        return _xapian.QueryParser_unstem_begin(self, *args)

    def unstem_end(self, *args):
        """
        TermIterator
        Xapian::QueryParser::unstem_end(const std::string &) const 
        """
        return _xapian.QueryParser_unstem_end(self, *args)

    def add_valuerangeprocessor(self, *args):
        """
        Register a ValueRangeProcessor.

        void
        Xapian::QueryParser::add_valuerangeprocessor(Xapian::ValueRangeProcessor
        *vrproc) 
        """
        return _xapian.QueryParser_add_valuerangeprocessor(self, *args)

    def get_corrected_query_string(self):
        """
        Get the spelling-corrected query string.

        std::string Xapian::QueryParser::get_corrected_query_string() const

        This will only be set if FLAG_SPELLING_CORRECTION is specified when
        QueryParser::parse_query() was last called.

        If there were no corrections, an empty string is returned. 
        """
        return _xapian.QueryParser_get_corrected_query_string(self)

    def __str__(self):
        """
        Return a string describing this object.

        std::string Xapian::QueryParser::get_description() const 
        """
        return _xapian.QueryParser___str__(self)

QueryParser.set_stemmer = new_instancemethod(_xapian.QueryParser_set_stemmer,None,QueryParser)
QueryParser.set_stemming_strategy = new_instancemethod(_xapian.QueryParser_set_stemming_strategy,None,QueryParser)
QueryParser.set_stopper = new_instancemethod(_xapian.QueryParser_set_stopper,None,QueryParser)
QueryParser.set_default_op = new_instancemethod(_xapian.QueryParser_set_default_op,None,QueryParser)
QueryParser.get_default_op = new_instancemethod(_xapian.QueryParser_get_default_op,None,QueryParser)
QueryParser.set_database = new_instancemethod(_xapian.QueryParser_set_database,None,QueryParser)
QueryParser.set_max_wildcard_expansion = new_instancemethod(_xapian.QueryParser_set_max_wildcard_expansion,None,QueryParser)
QueryParser.parse_query = new_instancemethod(_xapian.QueryParser_parse_query,None,QueryParser)
QueryParser.add_prefix = new_instancemethod(_xapian.QueryParser_add_prefix,None,QueryParser)
QueryParser.add_boolean_prefix = new_instancemethod(_xapian.QueryParser_add_boolean_prefix,None,QueryParser)
QueryParser.stoplist_begin = new_instancemethod(_xapian.QueryParser_stoplist_begin,None,QueryParser)
QueryParser.stoplist_end = new_instancemethod(_xapian.QueryParser_stoplist_end,None,QueryParser)
QueryParser.unstem_begin = new_instancemethod(_xapian.QueryParser_unstem_begin,None,QueryParser)
QueryParser.unstem_end = new_instancemethod(_xapian.QueryParser_unstem_end,None,QueryParser)
QueryParser.add_valuerangeprocessor = new_instancemethod(_xapian.QueryParser_add_valuerangeprocessor,None,QueryParser)
QueryParser.get_corrected_query_string = new_instancemethod(_xapian.QueryParser_get_corrected_query_string,None,QueryParser)
QueryParser.__str__ = new_instancemethod(_xapian.QueryParser___str__,None,QueryParser)
QueryParser_swigregister = _xapian.QueryParser_swigregister
QueryParser_swigregister(QueryParser)


def sortable_serialise(*args):
  return _xapian.sortable_serialise(*args)
sortable_serialise = _xapian.sortable_serialise

def sortable_unserialise(*args):
  return _xapian.sortable_unserialise(*args)
sortable_unserialise = _xapian.sortable_unserialise
class StemImplementation(object):
    """
    Class representing a stemming algorithm implementation. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    __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 __init__(self): 
        if self.__class__ == StemImplementation:
            _self = None
        else:
            _self = self
        _xapian.StemImplementation_swiginit(self,_xapian.new_StemImplementation(_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)

class Stem(object):
    """
    Class representing a stemming algorithm. 
    """
    thisown = _swig_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

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 = _swig_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, *args):
        """
        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, *args)

    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, *args):
        """
        Set the current document.

        void Xapian::TermGenerator::set_document(const Xapian::Document &doc)

        """
        return _xapian.TermGenerator_set_document(self, *args)

    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, *args):
        """
        Set the database to index spelling data to.

        void Xapian::TermGenerator::set_database(const
        Xapian::WritableDatabase &db) 
        """
        return _xapian.TermGenerator_set_database(self, *args)

    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
    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, *args):
        """
        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. This is the default strategy.

        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, *args)

    def set_max_word_length(self, *args):
        """
        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, *args)

    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::termcount
        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::termcount Xapian::TermGenerator::get_termpos() const 
        """
        return _xapian.TermGenerator_get_termpos(self)

    def set_termpos(self, *args):
        """
        Set the current term position.

        void Xapian::TermGenerator::set_termpos(Xapian::termcount termpos)

        Parameters:
        -----------

        termpos:  The new term position to set. 
        """
        return _xapian.TermGenerator_set_termpos(self, *args)

    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_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)

class KeyMaker(object):
    """
    Virtual base class for key making functors. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    __swig_destroy__ = _xapian.delete_KeyMaker
    def __init__(self): 
        if self.__class__ == KeyMaker:
            _self = None
        else:
            _self = self
        _xapian.KeyMaker_swiginit(self,_xapian.new_KeyMaker(_self, ))
    def __disown__(self):
        self.this.disown()
        _xapian.disown_KeyMaker(self)
        return weakref_proxy(self)
KeyMaker.__call__ = new_instancemethod(_xapian.KeyMaker___call__,None,KeyMaker)
KeyMaker_swigregister = _xapian.KeyMaker_swigregister
KeyMaker_swigregister(KeyMaker)

class MultiValueKeyMaker(KeyMaker):
    """
    KeyMaker subclass which combines several values.

    When the result is used for sorting, results are ordered by the first
    value. In the event of a tie, the second is used. If this is the same
    for both, the third is used, and so on. If reverse is true for a
    value, then the sort order for that value is reversed.

    When used for collapsing, the documents will only be considered equal
    if all the values specified match. If none of the specified values are
    set then the generated key will be empty, so such documents won't be
    collapsed (which is consistent with the behaviour in the "collapse on
    a value" case). If you'd prefer that documents with none of the keys
    set are collapsed together, then you can set reverse for at least one
    of the values. Other than this, it isn't useful to set reverse for
    collapsing. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self): 
        """
        Xapian::MultiValueKeyMaker::MultiValueKeyMaker(Iterator begin,
        Iterator end) 
        """
        _xapian.MultiValueKeyMaker_swiginit(self,_xapian.new_MultiValueKeyMaker())
    def add_value(self, *args):
        """
        void
        Xapian::MultiValueKeyMaker::add_value(Xapian::valueno slot, bool
        reverse=false) 
        """
        return _xapian.MultiValueKeyMaker_add_value(self, *args)

    __swig_destroy__ = _xapian.delete_MultiValueKeyMaker
MultiValueKeyMaker.add_value = new_instancemethod(_xapian.MultiValueKeyMaker_add_value,None,MultiValueKeyMaker)
MultiValueKeyMaker_swigregister = _xapian.MultiValueKeyMaker_swigregister
MultiValueKeyMaker_swigregister(MultiValueKeyMaker)

class Sorter(KeyMaker):
    """
    Virtual base class for sorter functor. 
    """
    thisown = _swig_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_Sorter
Sorter_swigregister = _xapian.Sorter_swigregister
Sorter_swigregister(Sorter)

class MultiValueSorter(Sorter):
    """
    Sorter subclass which sorts by a several values.

    Results are ordered by the first value. In the event of a tie, the
    second is used. If this is the same for both, the third is used, and
    so on.

    Deprecated This class is deprecated - you should migrate to using
    MultiValueKeyMaker instead. Note that MultiValueSorter::add() becomes
    MultiValueKeyMaker::add_value(), but the sense of the direction flag
    is reversed (to be consistent with Enquire::set_sort_by_value()).

    So: MultiValueSorter sorter;     // Primary ordering is forwards on
    value 4. sorter.add(4);     // Secondary ordering is reverse on value
    5. sorter.add(5, false); becomes: MultiValueKeyMaker sorter;     //
    Primary ordering is forwards on value 4. sorter.add_value(4);     //
    Secondary ordering is reverse on value 5. sorter.add_value(5, true);

    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    def __init__(self): 
        """
        Xapian::MultiValueSorter::MultiValueSorter(Iterator begin, Iterator
        end) 
        """
        _xapian.MultiValueSorter_swiginit(self,_xapian.new_MultiValueSorter())
    def add(self, *args):
        """
        void
        Xapian::MultiValueSorter::add(Xapian::valueno slot, bool forward=true)

        """
        return _xapian.MultiValueSorter_add(self, *args)

    __swig_destroy__ = _xapian.delete_MultiValueSorter
MultiValueSorter.add = new_instancemethod(_xapian.MultiValueSorter_add,None,MultiValueSorter)
MultiValueSorter_swigregister = _xapian.MultiValueSorter_swigregister
MultiValueSorter_swigregister(MultiValueSorter)

class ValueSetMatchDecider(MatchDecider):
    """
    MatchDecider filtering results based on whether document values are in
    a user- defined set. 
    """
    thisown = _swig_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 ValueSetMatchDecider.

        Xapian::ValueSetMatchDecider::ValueSetMatchDecider(Xapian::valueno
        slot, bool inclusive_)

        Parameters:
        -----------

        slot:  The value slot number to look in.

        inclusive_:  If true, match decider accepts documents which have a
        value in the specified slot which is a member of the test set; if
        false, match decider accepts documents which do not have a value in
        the specified slot. 
        """
        _xapian.ValueSetMatchDecider_swiginit(self,_xapian.new_ValueSetMatchDecider(*args))
    def add_value(self, *args):
        """
        Add a value to the test set.

        void Xapian::ValueSetMatchDecider::add_value(const std::string &value)

        Parameters:
        -----------

        value:  The value to add to the test set. 
        """
        return _xapian.ValueSetMatchDecider_add_value(self, *args)

    def remove_value(self, *args):
        """
        Remove a value from the test set.

        void Xapian::ValueSetMatchDecider::remove_value(const std::string
        &value)

        Parameters:
        -----------

        value:  The value to remove from the test set. 
        """
        return _xapian.ValueSetMatchDecider_remove_value(self, *args)

    __swig_destroy__ = _xapian.delete_ValueSetMatchDecider
ValueSetMatchDecider.add_value = new_instancemethod(_xapian.ValueSetMatchDecider_add_value,None,ValueSetMatchDecider)
ValueSetMatchDecider.remove_value = new_instancemethod(_xapian.ValueSetMatchDecider_remove_value,None,ValueSetMatchDecider)
ValueSetMatchDecider_swigregister = _xapian.ValueSetMatchDecider_swigregister
ValueSetMatchDecider_swigregister(ValueSetMatchDecider)

class Compactor(object):
    """
    Compact a database, or merge and compact several. 
    """
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
    __repr__ = _swig_repr
    STANDARD = _xapian.Compactor_STANDARD
    FULL = _xapian.Compactor_FULL
    FULLER = _xapian.Compactor_FULLER
    def __init__(self): 
        """Xapian::Compactor::Compactor() """
        if self.__class__ == Compactor:
            _self = None
        else:
            _self = self
        _xapian.Compactor_swiginit(self,_xapian.new_Compactor(_self, ))
    __swig_destroy__ = _xapian.delete_Compactor
    def set_block_size(self, *args):
        """
        Set the block size to use for tables in the output database.

        void Xapian::Compactor::set_block_size(size_t block_size)

        Parameters:
        -----------

        block_size:  The block size to use. Valid block sizes are currently
        powers of two between 2048 and 65536, with the default being 8192, but
        the valid sizes and default may change in the future. 
        """
        return _xapian.Compactor_set_block_size(self, *args)

    def set_renumber(self, *args):
        """
        Set whether to preserve existing document id values.

        void Xapian::Compactor::set_renumber(bool renumber)

        Parameters:
        -----------

        renumber:  The default is true, which means that document ids will be
        renumbered - currently by applying the same offset to all the document
        ids in a particular source database.

        If false, then the document ids must be unique over all source
        databases. Currently the ranges of document ids in each source must
        not overlap either, though this restriction may be removed in the
        future. 
        """
        return _xapian.Compactor_set_renumber(self, *args)

    def set_multipass(self, *args):
        """
        Set whether to merge postlists in multiple passes.

        void Xapian::Compactor::set_multipass(bool multipass)

        Parameters:
        -----------

        multipass:  If true and merging more than 3 databases, merge the
        postlists in multiple passes, which is generally faster but requires
        more disk space for temporary files. By default we don't do this. 
        """
        return _xapian.Compactor_set_multipass(self, *args)

    def set_compaction_level(self, *args):
        """
        Set the compaction level.

        void Xapian::Compactor::set_compaction_level(compaction_level
        compaction)

        Parameters:
        -----------

        compaction:  Available values are: Xapian::Compactor::STANDARD - Don't
        split items unnecessarily.

        Xapian::Compactor::FULL - Split items whenever it saves space (the
        default).

        Xapian::Compactor::FULLER - Allow oversize items to save more space
        (not recommended if you ever plan to update the compacted database).

        """
        return _xapian.Compactor_set_compaction_level(self, *args)

    def set_destdir(self, *args):
        """
        Set where to write the output.

        void Xapian::Compactor::set_destdir(const std::string &destdir)

        Parameters:
        -----------

        destdir:  Output path. This can be the same as an input if that input
        is a stub database (in which case the database(s) listed in the stub
        will be compacted to a new database and then the stub will be
        atomically updated to point to this new database). 
        """
        return _xapian.Compactor_set_destdir(self, *args)

    def add_source(self, *args):
        """
        Add a source database.

        void Xapian::Compactor::add_source(const std::string &srcdir)

        Parameters:
        -----------

        srcdir:  The path to the source database to add. 
        """
        return _xapian.Compactor_add_source(self, *args)

    def compact(self):
        """
        Perform the actual compaction/merging operation.

        void Xapian::Compactor::compact() 
        """
        return _xapian.Compactor_compact(self)

    def set_status(self, *args):
        """
        Update progress.

        virtual void Xapian::Compactor::set_status(const std::string &table,
        const std::string &status)

        Subclass this method if you want to get progress updates during
        compaction. This is called for each table first with empty status, And
        then one or more times with non-empty status.

        The default implementation does nothing.

        Parameters:
        -----------

        table:  The table currently being compacted.

        status:  A status message. 
        """
        return _xapian.Compactor_set_status(self, *args)

    def resolve_duplicate_metadata(self, *args):
        """
        Resolve multiple user metadata entries with the same key.

        virtual std::string
        Xapian::Compactor::resolve_duplicate_metadata(const std::string &key,
        size_t num_tags, const std::string tags[])

        When merging, if the same user metadata key is set in more than one
        input, then this method is called to allow this to be resolving in an
        appropriate way.

        The default implementation just returns tags[0].

        For multipass this will currently get called multiple times for the
        same key if there are duplicates to resolve in each pass, but this may
        change in the future.

        Parameters:
        -----------

        key:  The metadata key with duplicate entries.

        num_tags:  How many tags there are.

        tags:  An array of num_tags strings containing the tags to merge. 
        """
        return _xapian.Compactor_resolve_duplicate_metadata(self, *args)

    def __disown__(self):
        self.this.disown()
        _xapian.disown_Compactor(self)
        return weakref_proxy(self)
Compactor.set_block_size = new_instancemethod(_xapian.Compactor_set_block_size,None,Compactor)
Compactor.set_renumber = new_instancemethod(_xapian.Compactor_set_renumber,None,Compactor)
Compactor.set_multipass = new_instancemethod(_xapian.Compactor_set_multipass,None,Compactor)
Compactor.set_compaction_level = new_instancemethod(_xapian.Compactor_set_compaction_level,None,Compactor)
Compactor.set_destdir = new_instancemethod(_xapian.Compactor_set_destdir,None,Compactor)
Compactor.add_source = new_instancemethod(_xapian.Compactor_add_source,None,Compactor)
Compactor.compact = new_instancemethod(_xapian.Compactor_compact,None,Compactor)
Compactor.set_status = new_instancemethod(_xapian.Compactor_set_status,None,Compactor)
Compactor.resolve_duplicate_metadata = new_instancemethod(_xapian.Compactor_resolve_duplicate_metadata,None,Compactor)
Compactor_swigregister = _xapian.Compactor_swigregister
Compactor_swigregister(Compactor)

# Set the documentation format - this is used by tools like "epydoc" to decide
# how to format the documentation strings.
__docformat__ = "restructuredtext en"

##################################
# Support for iteration of MSets #
##################################

class MSetItem(object):
    """An item returned from iteration of the MSet.

    The item supports access to the following attributes and properties:

     - `docid`: The Xapian document ID corresponding to this MSet item.
     - `weight`: The weight corresponding to this MSet item.
     - `rank`: The rank of this MSet item.  The rank is the position in the
       total set of matching documents of this item.  The highest document is
       given a rank of 0.  If the MSet did not start at the highest matching
       document, because a non-zero 'start' parameter was supplied to
       get_mset(), the first document in the MSet will have a rank greater than
       0 (in fact, it will be equal to the value of 'start' supplied to
       get_mset()).
     - `percent`: The percentage score assigned to this MSet item.
     - `document`: The document for this MSet item.  This can be used to access
       the document data, or any other information stored in the document (such
       as term lists).  It is lazily evaluated.
     - `collapse_key`: The value of the key which was used for collapsing.
     - `collapse_count`: An estimate of the number of documents that have been
       collapsed into this one.

    The collapse count estimate will always be less than or equal to the actual
    number of other documents satisfying the match criteria with the same
    collapse key as this document.  If may be 0 even though there are other
    documents with the same collapse key which satisfying the match criteria.
    However if this method returns non-zero, there definitely are other such
    documents.  So this method may be used to inform the user that there are
    "at least N other matches in this group", or to control whether to offer a
    "show other documents in this group" feature (but note that it may not
    offer it in every case where it would show other documents).

    """

    __slots__ = ('_mset', '_firstitem', 'docid', 'weight', 'rank',
                 'percent', 'collapse_key', 'collapse_count', '_document', )

    def __init__(self, iter, mset):
        self._mset = mset
        self._firstitem = self._mset.get_firstitem()
        self.docid = iter.get_docid()
        self.weight = iter.get_weight()
        self.rank = iter.get_rank()
        self.percent = iter.get_percent()
        self.collapse_key = iter.get_collapse_key()
        self.collapse_count = iter.get_collapse_count()
        self._document = None

    def _get_document(self):
        if self._document is None:
            self._document = self._mset._get_hit_internal(self.rank - self._firstitem).get_document()
        return self._document

    document = property(_get_document, doc="The document object corresponding to this MSet item.")

class MSetIter(object):
    """An iterator over the items in an MSet.

    The iterator will return MSetItem objects, which will be evaluated lazily
    where appropriate.

    """
    __slots__ = ('_iter', '_end', '_mset')
    def __init__(self, mset):
        self._iter = mset.begin()
        self._end = mset.end()
        self._mset = mset

    def __iter__(self):
        return self

    # For Python2:
    def next(self):
        if self._iter == self._end:
            raise StopIteration
        else:
            r = MSetItem(self._iter, self._mset)
            self._iter.next()
            return r

    # For Python3:
    def __next__(self):
        if self._iter == self._end:
            raise StopIteration
        else:
            r = MSetItem(self._iter, self._mset)
            next(self._iter)
            return r


# Modify the MSet to allow access to the python iterators, and have other
# convenience methods.

def _mset_gen_iter(self):
    """Return an iterator over the MSet.

    The iterator will return MSetItem objects, which will be evaluated lazily
    where appropriate.

    """
    return MSetIter(self)
MSet.__iter__ = _mset_gen_iter

MSet.__len__ = lambda self: MSet.size(self)

def _mset_getitem(self, index):
    """Get an item from the MSet.

    The supplied index is relative to the start of the MSet, not the absolute
    rank of the item.

    Returns an MSetItem.

    """
    if index < 0:
        index += len(self)
    if index < 0 or index >= len(self):
        raise IndexError("Mset index out of range")
    return MSetItem(self._get_hit_internal(index), self)
MSet.__getitem__ = _mset_getitem
MSet.get_hit = _mset_getitem


##################################
# Support for iteration of ESets #
##################################

class ESetItem(object):
    """An item returned from iteration of the ESet.

    The item supports access to the following attributes:

     - `term`: The term corresponding to this ESet item.
     - `weight`: The weight corresponding to this ESet item.

    """
    __slots__ = ('term', 'weight')

    def __init__(self, iter):
        self.term = iter.get_term()
        self.weight = iter.get_weight()

class ESetIter(object):
    """An iterator over the items in an ESet.

    The iterator will return ESetItem objects.

    """
    __slots__ = ('_iter', '_end')
    def __init__(self, eset):
        self._iter = eset.begin()
        self._end = eset.end()

    def __iter__(self):
        return self

    # For Python2:
    def next(self):
        if self._iter == self._end:
            raise StopIteration
        else:
            r = ESetItem(self._iter)
            self._iter.next()
            return r

    # For Python3:
    def __next__(self):
        if self._iter == self._end:
            raise StopIteration
        else:
            r = ESetItem(self._iter)
            next(self._iter)
            return r

# Modify the ESet to allow access to the python iterators, and have other
# convenience methods.

def _eset_gen_iter(self):
    """Return an iterator over the ESet.
    
    The iterator will return ESetItem objects.

    """
    return ESetIter(self)
ESet.__iter__ = _eset_gen_iter

ESet.__len__ = lambda self: ESet.size(self)


#######################################
# Support for iteration of term lists #
#######################################

class TermListItem(object):
    """An item returned from iteration of a term list.

    The item supports access to the following attributes and properties:

     - `term`: The term corresponding to this TermListItem.
     - `wdf`: The within document frequency of this term.
     - `termfreq`: The number of documents in the collection which are indexed
       by the term
     - `positer`: An iterator over the positions which the term appears at in
       the document.  This is only available until the iterator which returned
       this item next moves.

    """
    __slots__ = ('_iter', 'term', '_wdf', '_termfreq')

    def __init__(self, iter, term):
        self._iter = iter
        self.term = term
        self._wdf = None
        self._termfreq = None

        if iter._has_wdf == TermIter.EAGER:
            self._wdf = iter._iter.get_wdf()
        if iter._has_termfreq == TermIter.EAGER:
            self._termfreq = iter._iter.get_termfreq()

        # Support for sequence API
        sequence = ['term', 'wdf', 'termfreq', 'positer']
        if iter._has_wdf == TermIter.INVALID:
            sequence[1] = 0
        if iter._has_termfreq == TermIter.INVALID:
            sequence[2] = 0
        if iter._has_positions == TermIter.INVALID:
            sequence[3] = PositionIter()

    def _get_wdf(self):
        """Get the within-document-frequency of the current term.

        This will raise a InvalidOperationError exception if the iterator this
        item came from doesn't support within-document-frequencies.

        """
        if self._wdf is None:
            if self._iter._has_wdf == TermIter.INVALID:
                raise InvalidOperationError("Iterator does not support wdfs")
            if self.term is not self._iter._lastterm:
                raise InvalidOperationError("Iterator has moved, and does not support random access")
            self._wdf = self._iter._iter.get_wdf()
        return self._wdf
    wdf = property(_get_wdf, doc=
    """The within-document-frequency of the current term (if meaningful).

    This will raise a InvalidOperationError exception if the iterator
    this item came from doesn't support within-document-frequencies.

    """)

    def _get_termfreq(self):
        """Get the term frequency.

        This is the number of documents in the collection which are indexed by
        the term.

        This will raise a InvalidOperationError exception if the iterator this
        item came from doesn't support term frequencies.

        """
        if self._termfreq is None:
            if self._iter._has_termfreq == TermIter.INVALID:
                raise InvalidOperationError("Iterator does not support term frequencies")
            if self.term is not self._iter._lastterm:
                raise InvalidOperationError("Iterator has moved, and does not support random access")
            self._termfreq = self._iter._iter.get_termfreq()
        return self._termfreq
    termfreq = property(_get_termfreq, doc=
    """The term frequency of the current term (if meaningful).

    This is the number of documents in the collection which are indexed by the
    term.

    This will raise a InvalidOperationError exception if the iterator
    this item came from doesn't support term frequencies.

    """)

    def _get_positer(self):
        """Get a position list iterator.

        The iterator will return integers representing the positions that the
        term occurs at.

        This will raise a InvalidOperationError exception if the iterator this
        item came from doesn't support position lists, or if the iterator has
        moved on since the item was returned from it.

        """
        if self._iter._has_positions == TermIter.INVALID:
            raise InvalidOperationError("Iterator does not support position lists")
        # Access to position lists is always lazy, so we don't need to check
        # _has_positions.
        if self.term is not self._iter._lastterm:
            raise InvalidOperationError("Iterator has moved, and does not support random access")
        return PositionIter(self._iter._iter.positionlist_begin(),
                            self._iter._iter.positionlist_end())
    positer = property(_get_positer, doc=
    """A position iterator for the current term (if meaningful).

    The iterator will return integers representing the positions that the term
    occurs at.

    This will raise a InvalidOperationError exception if the iterator this item
    came from doesn't support position lists, or if the iterator has moved on
    since the item was returned from it.

    """)


class TermIter(object):
    """An iterator over a term list.

    The iterator will return TermListItem objects, which will be evaluated
    lazily where appropriate.

    """
    __slots__ = ('_iter', '_end', '_has_termfreq', '_has_wdf',
                 '_has_positions', '_return_strings', '_lastterm', '_moved')

    INVALID = 0
    LAZY = 1
    EAGER = 2

    def __init__(self, start, end, has_termfreq=INVALID,
                 has_wdf=INVALID, has_positions=INVALID,
                 return_strings=False):
        self._iter = start
        self._end = end
        self._has_termfreq = has_termfreq
        self._has_wdf = has_wdf
        self._has_positions = has_positions
        assert(has_positions != TermIter.EAGER) # Can't do eager access to position lists
        self._return_strings = return_strings
        self._lastterm = None # Used to test if the iterator has moved

        # _moved is True if we've moved onto the next item.  This is needed so
        # that the iterator doesn't have to move on until just before next() is
        # called: since the iterator starts by pointing at a valid item, we
        # can't just call self._iter.next() unconditionally at the start of our
        # next() method.
        self._moved = True

    def __iter__(self):
        return self

    # For Python2:
    def next(self):
        if not self._moved:
            self._iter.next()
            self._moved = True

        if self._iter == self._end:
            self._lastterm = None
            raise StopIteration
        else:
            self._lastterm = self._iter.get_term()
            self._moved = False
            if self._return_strings:
                return self._lastterm
            return TermListItem(self, self._lastterm)

    # For Python3:
    def __next__(self):
        if not self._moved:
            next(self._iter)
            self._moved = True

        if self._iter == self._end:
            self._lastterm = None
            raise StopIteration
        else:
            self._lastterm = self._iter.get_term()
            self._moved = False
            if self._return_strings:
                return self._lastterm
            return TermListItem(self, self._lastterm)

    def skip_to(self, term):
        """Skip the iterator forward.

        The iterator is advanced to the first term at or after the current
        position which is greater than or equal to the supplied term.

        If there are no such items, this will raise StopIteration.

        This returns the item which the iterator is moved to.  The subsequent
        item will be returned the next time that next() is called (unless
        skip_to() is called again first).

        """
        if self._iter != self._end:
            self._iter.skip_to(term)

        if self._iter == self._end:
            self._lastterm = None
            self._moved = True
            raise StopIteration

        # Update self._lastterm if the iterator has moved.
        # TermListItems compare a saved value of lastterm with self._lastterm
        # with the object identity comparator, so it is important to ensure
        # that it does not get modified if the new term compares equal.
        newterm = self._iter.get_term()
        if newterm != self._lastterm:
            self._lastterm = newterm

        self._moved = False
        if self._return_strings:
            return self._lastterm
        return TermListItem(self, self._lastterm)

# Modify Enquire to add a "matching_terms()" method.
def _enquire_gen_iter(self, which):
    """Get an iterator over the terms which match a given match set item.

    The match set item to consider is specified by the `which` parameter, which
    may be a document ID, or an MSetItem object.

    The iterator will return string objects.

    """
    if isinstance(which, MSetItem):
        which = which.docid
    return TermIter(self.get_matching_terms_begin(which),
                    self.get_matching_terms_end(which),
                    return_strings=True)
Enquire.matching_terms = _enquire_gen_iter

# Modify Query to add an "__iter__()" method.
def _query_gen_iter(self):
    """Get an iterator over the terms in a query.

    The iterator will return string objects.

    """
    return TermIter(self.get_terms_begin(),
                    self.get_terms_end(),
                    return_strings=True)
Query.__iter__ = _query_gen_iter

# Modify Database to add an "__iter__()" method and an "allterms()" method.
def _database_gen_allterms_iter(self, prefix=None):
    """Get an iterator over all the terms in the database.

    The iterator will return TermListItem objects, but these will not support
    access to wdf, or position information.

    Access to term frequency information is only available until the iterator
    has moved on.

    If prefix is supplied, only terms which start with that prefix will be
    returned.

    """
    if prefix is None:
        return TermIter(self.allterms_begin(), self.allterms_end(),
                        has_termfreq=TermIter.LAZY)
    else:
        return TermIter(self.allterms_begin(prefix), self.allterms_end(prefix),
                        has_termfreq=TermIter.LAZY)
Database.__iter__ = _database_gen_allterms_iter
Database.allterms = _database_gen_allterms_iter

# Modify Database to add a "termlist()" method.
def _database_gen_termlist_iter(self, docid):
    """Get an iterator over all the terms which index a given document ID.

    The iterator will return TermListItem objects.

    Access to term frequency and position information is only available until
    the iterator has moved on.

    """
    # Note: has_termfreq is set to LAZY because most databases don't store term
    # frequencies in the termlist (because this would require updating many termlist
    # entries for every document update), so access to the term frequency requires a
    # separate lookup.
    return TermIter(self.termlist_begin(docid), self.termlist_end(docid),
                    has_termfreq=TermIter.LAZY,
                    has_wdf=TermIter.EAGER,
                    has_positions=TermIter.LAZY)
Database.termlist = _database_gen_termlist_iter

# Modify Database to add a "spellings()" method.
def _database_gen_spellings_iter(self):
    """Get an iterator which returns all the spelling correction targets

    The iterator will return TermListItem objects.  Only the term frequency is
    available; wdf and positions are not meaningful.

    """
    return TermIter(self.spellings_begin(), self.spellings_end(),
                    has_termfreq=TermIter.EAGER,
                    has_wdf=TermIter.INVALID,
                    has_positions=TermIter.INVALID)
Database.spellings = _database_gen_spellings_iter

# Modify Database to add a "synonyms()" method.
def _database_gen_synonyms_iter(self, term):
    """Get an iterator which returns all the synonyms for a given term.

    The term to return synonyms for is specified by the `term` parameter.

    The iterator will return string objects.

    """
    return TermIter(self.synonyms_begin(term),
                    self.synonyms_end(term),
                    return_strings=True)
Database.synonyms = _database_gen_synonyms_iter

# Modify Database to add a "synonym_keys()" method.
def _database_gen_synonym_keys_iter(self, prefix=""):
    """Get an iterator which returns all the terms which have synonyms.

    The iterator will return string objects.

    If `prefix` is non-empty, only terms with this prefix are returned.

    """
    return TermIter(self.synonym_keys_begin(prefix),
                    self.synonym_keys_end(prefix),
                    return_strings=True)
Database.synonym_keys = _database_gen_synonym_keys_iter

# Modify Database to add a "metadata_keys()" method, instead of direct access
# to metadata_keys_begin and metadata_keys_end.
def _database_gen_metadata_keys_iter(self, prefix=""):
    """Get an iterator which returns all the metadata keys.

    The iterator will return string objects.

    If `prefix` is non-empty, only metadata keys with this prefix are returned.

    """
    return TermIter(self._metadata_keys_begin(prefix),
                    self._metadata_keys_end(prefix),
                    return_strings=True)
Database.metadata_keys = _database_gen_metadata_keys_iter

# Modify Document to add an "__iter__()" method and a "termlist()" method.
def _document_gen_termlist_iter(self):
    """Get an iterator over all the terms in a document.

    The iterator will return TermListItem objects.

    Access to term frequency and position information is only available until
    the iterator has moved on.

    Note that term frequency information is only meaningful for a document
    retrieved from a database.  If term frequency information is requested for
    a document which was freshly created, an InvalidOperationError will be
    raised.

    """
    # Note: document termlist iterators may be implemented entirely in-memory
    # (in which case access to all items could be allowed eagerly), but may
    # also be implemented by returning a database termlist (for documents which
    # are stored in a database, rather than freshly created).  We choose the
    # most conservative settings, to avoid doing eager access when lazy access
    # would be more appropriate.
    return TermIter(self.termlist_begin(), self.termlist_end(),
                    has_termfreq=TermIter.LAZY,
                    has_wdf=TermIter.EAGER,
                    has_positions=TermIter.LAZY)
Document.__iter__ = _document_gen_termlist_iter
Document.termlist = _document_gen_termlist_iter

# Modify QueryParser to add a "stoplist()" method.
def _queryparser_gen_stoplist_iter(self):
    """Get an iterator over all the stopped terms from the previous query.
    
    This returns an iterator over all the terms which were omitted from the
    previously parsed query due to being considered to be stopwords.  Each
    instance of a word omitted from the query is represented in the returned
    list, in the order in which the

    The iterator will return string objects.

    """
    return TermIter(self.stoplist_begin(), self.stoplist_end(),
                    return_strings=True)
QueryParser.stoplist = _queryparser_gen_stoplist_iter

# Modify QueryParser to add an "unstemlist()" method.
def _queryparser_gen_unstemlist_iter(self, tname):
    """Get an iterator over all the unstemmed forms of a stemmed term.
    
    This returns an iterator which returns all the unstemmed words which were
    stemmed to the stemmed form specified by `tname` when parsing the previous
    query.  Each instance of a word which stems to `tname` is returned by the
    iterator in the order in which the words appeared in the query - an
    individual unstemmed word may thus occur multiple times.

    The iterator will return string objects.

    """
    return TermIter(self.unstem_begin(tname), self.unstem_end(tname),
                    return_strings=True)
QueryParser.unstemlist = _queryparser_gen_unstemlist_iter

# Modify ValueCountMatchSpy to add an "values()" method.
def wrapper():
    begin = ValueCountMatchSpy.values_begin
    del ValueCountMatchSpy.values_begin
    end = ValueCountMatchSpy.values_end
    del ValueCountMatchSpy.values_end
    def values_iter(self):
        """Get an iterator over all the values in the slot.

        Values will be returned in ascending alphabetical order.

        The iterator will return TermListItem objects: the value can be
        accessed as the `term` property, and the frequency can be accessed as
        the `termfreq` property.

        """
        return TermIter(begin(self), end(self), has_termfreq=TermIter.EAGER)
    return values_iter
ValueCountMatchSpy.values = wrapper()
del wrapper

# Modify ValueCountMatchSpy to add an "top_values()" method.
def wrapper():
    begin = ValueCountMatchSpy.top_values_begin
    del ValueCountMatchSpy.top_values_begin
    end = ValueCountMatchSpy.top_values_end
    del ValueCountMatchSpy.top_values_end
    def top_values_iter(self, maxvalues):
        """Get an iterator over the most frequent values for the slot.

        Values will be returned in descending order of frequency.  Values with
        the same frequency will be returned in ascending alphabetical order.

        The iterator will return TermListItem objects: the value can be
        accessed as the `term` property, and the frequency can be accessed as
        the `termfreq` property.

        """
        return TermIter(begin(self, maxvalues), end(self, maxvalues),
                        has_termfreq=TermIter.EAGER)
    return top_values_iter
ValueCountMatchSpy.top_values = wrapper()
del wrapper

# When we make a query, keep a note of postingsources involved, so they won't
# be deleted. This hack can probably be removed once xapian bug #186 is fixed.
__query_init_orig = Query.__init__
def _query_init(self, *args):
    """Make a new query object.

    Many possible arguments are possible - see the documentation for details.

    """
    ps = []
    if len(args) == 1 and isinstance(args[0], PostingSource):
        ps.append(args[0])
    else:
        for arg in args:
            if isinstance(arg, Query):
                ps.extend(getattr(arg, '_ps', []))
            elif hasattr(arg, '__iter__'):
                for listarg in arg:
                    if isinstance(listarg, Query):
                        ps.extend(getattr(listarg, '_ps', []))
    __query_init_orig(self, *args)
    self._ps = ps
Query.__init__ = _query_init
del _query_init

# When setting a query on enquire, keep a note of postingsources involved, so
# they won't be deleted. This hack can probably be removed once xapian bug #186
# is fixed.
__enquire_set_query_orig = Enquire.set_query
def _enquire_set_query(self, query, qlen=0):
    self._ps = getattr(query, '_ps', [])
    return __enquire_set_query_orig(self, query, qlen)
_enquire_set_query.__doc__ = __enquire_set_query_orig.__doc__
Enquire.set_query = _enquire_set_query
del _enquire_set_query

# When getting  a query from enquire, keep a note of postingsources involved,
# so they won't be deleted. This hack can probably be removed once xapian bug
# #186 is fixed.
__enquire_get_query_orig = Enquire.get_query
def _enquire_get_query(self):
    query = __enquire_get_query_orig(self)
    query._ps = getattr(self, '_ps', [])
    return query
_enquire_get_query.__doc__ = __enquire_get_query_orig.__doc__
Enquire.get_query = _enquire_get_query
del _enquire_get_query

# When we set a ValueRangeProcessor into the QueryParser, keep a python
# reference so it won't be deleted. This hack can probably be removed once
# xapian bug #186 is fixed.
__queryparser_add_valuerangeprocessor_orig = QueryParser.add_valuerangeprocessor
def _queryparser_add_valuerangeprocessor(self, vrproc):
    if not hasattr(self, '_vrps'):
        self._vrps = []
    self._vrps.append(vrproc)
    return __queryparser_add_valuerangeprocessor_orig(self, vrproc)
_queryparser_add_valuerangeprocessor.__doc__ = __queryparser_add_valuerangeprocessor_orig.__doc__
QueryParser.add_valuerangeprocessor = _queryparser_add_valuerangeprocessor
del _queryparser_add_valuerangeprocessor

# When we set a Stopper into the QueryParser, keep a python reference so it
# won't be deleted. This hack can probably be removed once xapian bug #186 is
# fixed.
__queryparser_set_stopper_orig = QueryParser.set_stopper
def _queryparser_set_stopper(self, stopper):
    self._stopper = stopper
    return __queryparser_set_stopper_orig(self, stopper)
_queryparser_set_stopper.__doc__ = __queryparser_set_stopper_orig.__doc__
QueryParser.set_stopper = _queryparser_set_stopper
del _queryparser_set_stopper

# When we set a Stopper into the TermGenerator, keep a python reference so it
# won't be deleted. This hack can probably be removed once xapian bug #186 is
# fixed.
__termgenerator_set_stopper_orig = TermGenerator.set_stopper
def _termgenerator_set_stopper(self, stopper):
    self._stopper = stopper
    return __termgenerator_set_stopper_orig(self, stopper)
_termgenerator_set_stopper.__doc__ = __termgenerator_set_stopper_orig.__doc__
TermGenerator.set_stopper = _termgenerator_set_stopper
del _termgenerator_set_stopper

def _enquire_check_deprec_args(reverse, kwargs, methodname):
    """Check the keyword arguments to one of the enquire set_sort_* methods.
    
    """
    if reverse is not None:
        if 'ascending' in kwargs:
            raise TypeError('Only one of "reverse" and "ascending" may be specified')
        if len(kwargs) != 0:
            raise TypeError('Only keyword arguments allowed are "reverse" and "ascending"')
    else:
        import warnings
        if 'ascending' in kwargs:
            reverse = kwargs.get('ascending')
            del kwargs['ascending']
            warnings.warn("'ascending' as a parameter name to Enquire::" +
                          methodname + "() is deprecated and will be removed "
                          "in Xapian 1.3.0", DeprecationWarning)
        else:
            warnings.warn("Single argument form of Enquire::" +
                          methodname + "() is deprecated and will be removed "
                          "in Xapian 1.3.0", DeprecationWarning)
            reverse = True
        if len(kwargs) != 0:
            raise TypeError('Only keyword arguments allowed are "reverse" and "ascending"')
    return reverse

# When we set a Sorter on enquire, keep a python reference so it won't be
# deleted.  This hack can probably be removed once xapian bug #186 is fixed.
__enquire_set_sort_by_key_orig = Enquire.set_sort_by_key
def _enquire_set_sort_by_key(self, sorter, reverse=None, **kwargs):
    self._sorter = sorter
    reverse = _enquire_check_deprec_args(reverse, kwargs, "set_sort_by_key")
    return __enquire_set_sort_by_key_orig(self, sorter, reverse)
_enquire_set_sort_by_key.__doc__ = __enquire_set_sort_by_key_orig.__doc__
Enquire.set_sort_by_key = _enquire_set_sort_by_key
del _enquire_set_sort_by_key

__enquire_set_sort_by_key_then_relevance_orig = Enquire.set_sort_by_key_then_relevance
def _enquire_set_sort_by_key_then_relevance(self, sorter, reverse=None, **kwargs):
    self._sorter = sorter
    reverse = _enquire_check_deprec_args(reverse, kwargs, "set_sort_by_key_then_relevance")
    return __enquire_set_sort_by_key_then_relevance_orig(self, sorter, reverse)
_enquire_set_sort_by_key_then_relevance.__doc__ = __enquire_set_sort_by_key_then_relevance_orig.__doc__
Enquire.set_sort_by_key_then_relevance = _enquire_set_sort_by_key_then_relevance
del _enquire_set_sort_by_key_then_relevance

__enquire_set_sort_by_relevance_then_key_orig = Enquire.set_sort_by_relevance_then_key
def _enquire_set_sort_by_relevance_then_key(self, sorter, reverse=None, **kwargs):
    self._sorter = sorter
    reverse = _enquire_check_deprec_args(reverse, kwargs, "set_sort_by_relevance_then_key")
    return __enquire_set_sort_by_relevance_then_key_orig(self, sorter, reverse)
_enquire_set_sort_by_relevance_then_key.__doc__ = __enquire_set_sort_by_relevance_then_key_orig.__doc__
Enquire.set_sort_by_relevance_then_key = _enquire_set_sort_by_relevance_then_key
del _enquire_set_sort_by_relevance_then_key

# Add deprecation warnings about old argument names.  Can be removed in 1.3.0
__enquire_set_sort_by_value_orig = Enquire.set_sort_by_value
def _enquire_set_sort_by_value(self, sort_key, reverse=None, **kwargs):
    reverse = _enquire_check_deprec_args(reverse, kwargs, "set_sort_by_value")
    return __enquire_set_sort_by_value_orig(self, sort_key, reverse)
_enquire_set_sort_by_value.__doc__ = __enquire_set_sort_by_value_orig.__doc__
Enquire.set_sort_by_value = _enquire_set_sort_by_value
del _enquire_set_sort_by_value

# Add deprecation warnings about old argument names.  Can be removed in 1.3.0
__enquire_set_sort_by_relevance_then_value_orig = Enquire.set_sort_by_relevance_then_value
def _enquire_set_sort_by_relevance_then_value(self, sort_key, reverse=None, **kwargs):
    reverse = _enquire_check_deprec_args(reverse, kwargs, "set_sort_by_relevance_then_value")
    return __enquire_set_sort_by_relevance_then_value_orig(self, sort_key, reverse)
_enquire_set_sort_by_relevance_then_value.__doc__ = __enquire_set_sort_by_relevance_then_value_orig.__doc__
Enquire.set_sort_by_relevance_then_value = _enquire_set_sort_by_relevance_then_value
del _enquire_set_sort_by_relevance_then_value

# Add deprecation warnings about old argument names.  Can be removed in 1.3.0
__enquire_set_sort_by_value_then_relevance_orig = Enquire.set_sort_by_value_then_relevance
def _enquire_set_sort_by_value_then_relevance(self, sort_key, reverse=None, **kwargs):
    reverse = _enquire_check_deprec_args(reverse, kwargs, "set_sort_by_value_then_relevance")
    return __enquire_set_sort_by_value_then_relevance_orig(self, sort_key, reverse)
_enquire_set_sort_by_value_then_relevance.__doc__ = __enquire_set_sort_by_value_then_relevance_orig.__doc__
Enquire.set_sort_by_value_then_relevance = _enquire_set_sort_by_value_then_relevance
del _enquire_set_sort_by_value_then_relevance


##########################################
# Support for iteration of posting lists #
##########################################

class PostingItem(object):
    """An item returned from iteration of a posting list.

    The item supports access to the following attributes and properties:

     - `docid`: The document ID corresponding to this PostingItem.
     - `doclength`: The length of the document corresponding to this
       PostingItem.
     - `wdf`: The within document frequency of the term which the posting list
       is for in the document corresponding to this PostingItem.
     - `positer`: An iterator over the positions which the term corresponing to
       this posting list occurs at in the document corresponding to this
       PostingItem.  This is only available until the iterator which returned
       this item next moves.

    """
    __slots__ = ('_iter', 'docid', 'doclength', 'wdf',)

    def __init__(self, iter):
        self._iter = iter
        self.docid = iter._iter.get_docid()
        self.doclength = iter._iter.get_doclength()
        self.wdf = iter._iter.get_wdf()

        # Support for sequence API
        sequence = ['docid', 'doclength', 'wdf', 'positer']
        if not iter._has_positions:
            sequence[3] = PositionIter()

    def _get_positer(self):
        """Get a position list iterator.

        The iterator will return integers representing the positions that the
        term occurs at in the document corresponding to this PostingItem.

        This will raise a InvalidOperationError exception if the iterator this
        item came from doesn't support position lists, or if the iterator has
        moved on since the item was returned from it.

        """
        if not self._iter._has_positions:
            raise InvalidOperationError("Iterator does not support position lists")
        if self._iter._iter == self._iter._end or \
           self.docid != self._iter._iter.get_docid():
            raise InvalidOperationError("Iterator has moved, and does not support random access")
        return PositionIter(self._iter._iter.positionlist_begin(),
                            self._iter._iter.positionlist_end())
    positer = property(_get_positer, doc=
    """A position iterator for the current posting (if meaningful).

    The iterator will return integers representing the positions that the term
    occurs at.

    This will raise a InvalidOperationError exception if the iterator this item
    came from doesn't support position lists, or if the iterator has moved on
    since the item was returned from it.

    """)


class PostingIter(object):
    """An iterator over a posting list.

    The iterator will return PostingItem objects, which will be evaluated
    lazily where appropriate.

    """
    __slots__ = ('_iter', '_end', '_has_positions', '_moved')

    def __init__(self, start, end, has_positions=False):
        self._iter = start
        self._end = end
        self._has_positions = has_positions

        # _moved is True if we've moved onto the next item.  This is needed so
        # that the iterator doesn't have to move on until just before next() is
        # called: since the iterator starts by pointing at a valid item, we
        # can't just call self._iter.next() unconditionally at the start of our
        # next() method.
        self._moved = True

    def __iter__(self):
        return self

    # For Python2:
    def next(self):
        if not self._moved:
            self._iter.next()
            self._moved = True

        if self._iter == self._end:
            raise StopIteration
        else:
            self._moved = False
            return PostingItem(self)

    # For Python3:
    def __next__(self):
        if not self._moved:
            next(self._iter)
            self._moved = True

        if self._iter == self._end:
            raise StopIteration
        else:
            self._moved = False
            return PostingItem(self)

    def skip_to(self, docid):
        """Skip the iterator forward.

        The iterator is advanced to the first document with a document ID
        which is greater than or equal to the supplied document ID.

        If there are no such items, this will raise StopIteration.

        This returns the item which the iterator is moved to.  The subsequent
        item will be returned the next time that next() is called (unless
        skip_to() is called again first).

        """
        if self._iter != self._end:
            self._iter.skip_to(docid)
        if self._iter == self._end:
            self._moved = True
            raise StopIteration
        self._moved = False
        return PostingItem(self)

def _database_gen_postlist_iter(self, tname):
    """Get an iterator over the postings which are indexed by a given term.

    If `tname` is empty, an iterator over all the documents will be returned
    (this will contain one entry for each document, will always return a wdf of
    1, and will not allow access to a position iterator).

    """
    if len(tname) != 0:
        return PostingIter(self.postlist_begin(tname), self.postlist_end(tname),
                           has_positions=True)
    else:
        return PostingIter(self.postlist_begin(tname), self.postlist_end(tname))
Database.postlist = _database_gen_postlist_iter


###########################################
# Support for iteration of position lists #
###########################################

class PositionIter(object):
    """An iterator over a position list.

    The iterator will return integers, in ascending order.

    """
    def __init__(self, start = 0, end = 0):
        self.iter = start
        self.end = end

    def __iter__(self):
        return self

    # For Python2:
    def next(self):
        if self.iter==self.end:
            raise StopIteration
        else:
            r = self.iter.get_termpos()
            self.iter.next()
            return r

    # For Python3:
    def __next__(self):
        if self.iter==self.end:
            raise StopIteration
        else:
            r = self.iter.get_termpos()
            next(self.iter)
            return r

# Modify Database to add a "positionlist()" method.
def _database_gen_positionlist_iter(self, docid, tname):
    """Get an iterator over all the positions in a given document of a term.
    
    The iterator will return integers, in ascending order.

    """
    return PositionIter(self.positionlist_begin(docid, tname), self.positionlist_end(docid, tname))
Database.positionlist = _database_gen_positionlist_iter

########################################
# Support for iteration of value lists #
########################################

class ValueItem(object):
    """An item returned from iteration of the values in a document.

    The item supports access to the following attributes:

     - `num`: The number of the value.
     - `value`: The contents of the value.

    """

    __slots__ = ('num', 'value', )

    def __init__(self, num, value):
        self.num = num
        self.value = value

class ValueIter(object):
    """An iterator over all the values stored in a document.

    The iterator will return ValueItem objects, in ascending order of value number.

    """
    def __init__(self, start, end):
        self.iter = start
        self.end = end

    def __iter__(self):
        return self

    # For Python2:
    def next(self):
        if self.iter==self.end:
            raise StopIteration
        else:
            r = ValueItem(self.iter.get_valueno(), self.iter.get_value())
            self.iter.next()
            return r

    # For Python3:
    def __next__(self):
        if self.iter==self.end:
            raise StopIteration
        else:
            r = ValueItem(self.iter.get_valueno(), self.iter.get_value())
            next(self.iter)
            return r

# Modify Document to add a "values()" method.
def _document_gen_values_iter(self):
    """Get an iterator over all the values stored in a document.

    The iterator will return ValueItem objects, in ascending order of value number.

    """
    return ValueIter(self.values_begin(), self.values_end())
Document.values = _document_gen_values_iter


##########################################
# Support for iteration of value streams #
##########################################

class ValueStreamItem(object):
    """An item returned from iteration of the values in a document.

    The item supports access to the following attributes:

     - `docid`: The docid for the item.
     - `value`: The contents of the value.

    """

    __slots__ = ('docid', 'value', )

    def __init__(self, docid, value):
        self.docid = docid
        self.value = value

class ValueStreamIter(object):
    """An iterator over all the values stored in a document.

    The iterator will return ValueStreamItem objects, in ascending order of value number.

    """
    def __init__(self, start, end):
        self.iter = start
        self.end = end
        self.moved = True

    def __iter__(self):
        return self

    # For Python2:
    def next(self):
        if not self.moved:
            self.iter.next()
            self.moved = True

        if self.iter==self.end:
            raise StopIteration
        else:
            self.moved = False
            return ValueStreamItem(self.iter.get_docid(), self.iter.get_value())

    # For Python3:
    def __next__(self):
        if not self.moved:
            self.iter.next()
            self.moved = True

        if self.iter==self.end:
            raise StopIteration
        else:
            self.moved = False
            return ValueStreamItem(self.iter.get_docid(), self.iter.get_value())

    def skip_to(self, docid):
        """Skip the iterator forward.

        The iterator is advanced to the first document with a document ID
        which is greater than or equal to the supplied document ID.

        If there are no such items, this will raise StopIteration.

        This returns the item which the iterator is moved to.  The subsequent
        item will be returned the next time that next() is called (unless
        skip_to() is called again first).

        """
        if self.iter != self.end:
            self.iter.skip_to(docid)
        if self.iter == self.end:
            self.moved = True
            raise StopIteration
        self.moved = False
        return ValueStreamItem(self.iter.get_docid(), self.iter.get_value())

# Modify Database to add a "valuestream()" method, and remove the
# valuestream_begin() and valuestream_end() methods.
def wrapper():
    vs_begin = Database.valuestream_begin
    vs_end = Database.valuestream_end
    def _database_gen_valuestream_iter(self, slot):
        """Get an iterator over all the values stored in a slot in the database.

        The iterator will return ValueStreamItem objects, in ascending order of
        document id.

        """
        return ValueStreamIter(vs_begin(self, slot), vs_end(self, slot))
    return _database_gen_valuestream_iter
Database.valuestream = wrapper()
del wrapper
del Database.valuestream_begin
del Database.valuestream_end

# Fix up Enquire so that it keeps a python reference to the deciders supplied
# to it so that they won't be deleted before the Enquire object.  This hack can
# probably be removed once xapian bug #186 is fixed.
_enquire_add_matchspy_orig = Enquire.add_matchspy
def _enquire_match_spy_add(self, decider):
    if not hasattr(self, '_deciders'):
        self._deciders = []
    self._deciders.append(decider)
    _enquire_add_matchspy_orig(self, decider)
_enquire_match_spy_add.__doc__ = Enquire.add_matchspy.__doc__
Enquire.add_matchspy = _enquire_match_spy_add

_enquire_clear_matchspies_orig = Enquire.clear_matchspies
def _enquire_match_spies_clear(self):
    _enquire_clear_matchspies_orig(self)
    if hasattr(self, '_deciders'):
        del self._deciders
_enquire_match_spies_clear.__doc__ = Enquire.clear_matchspies.__doc__
Enquire.clear_matchspies = _enquire_match_spies_clear


# Fix up Stem.__init__() so that it calls __disown__() on the passed
# StemImplementation object so that Python won't delete it from under us.
_stem_init_orig = Stem.__init__
def _stem_init(self, *args):
    _stem_init_orig(self, *args)
    if len(args) > 0 and isinstance(args[0], StemImplementation):
        args[0].__disown__()
_stem_init.__doc__ = Stem.__init__.__doc__
Stem.__init__ = _stem_init


# Remove static methods which shouldn't be in the API.
del Document_unserialise
del Query_unserialise

# Add wrappers for Query::MatchAll and Query::MatchNothing
Query.MatchAll = Query("")
Query.MatchNothing = Query()

# Require to support the non-pythonic iterators for Python 3 - these can be
# removed once support for the non-pythonic iterators is dropped in 1.3.0.
ESetIterator.__next__ = lambda self: ESetIterator.next(self)
MSetIterator.__next__ = lambda self: MSetIterator.next(self)
PostingIterator.__next__ = lambda self: PostingIterator.next(self)
PositionIterator.__next__ = lambda self: PositionIterator.next(self)
TermIterator.__next__ = lambda self: TermIterator.next(self)
ValueIterator.__next__ = lambda self: ValueIterator.next(self)


# Set the list of names which should be public.
# Note that this needs to happen at the end of xapian.py.
__all__ = []
for item in dir():
    if item.startswith('_') or item.endswith('_swigregister') or item.endswith('Iterator'):
        continue
    __all__.append(item)
__all__ = tuple(__all__)



