1# This file was automatically generated by SWIG (http://www.swig.org).
2# Version 2.0.5
3#
4# Do not make changes to this file unless you know what you are doing--modify
5# the SWIG interface file instead.
6
7
8
9from sys import version_info
10if version_info >= (3,0,0):
11    new_instancemethod = lambda func, inst, cls: _xapian.SWIG_PyInstanceMethod_New(func)
12else:
13    from new import instancemethod as new_instancemethod
14if version_info >= (2,6,0):
15    def swig_import_helper():
16        from os.path import dirname
17        import imp
18        fp = None
19        try:
20            fp, pathname, description = imp.find_module('_xapian', [dirname(__file__)])
21        except ImportError:
22            import _xapian
23            return _xapian
24        if fp is not None:
25            try:
26                _mod = imp.load_module('_xapian', fp, pathname, description)
27            finally:
28                fp.close()
29            return _mod
30    _xapian = swig_import_helper()
31    del swig_import_helper
32else:
33    import _xapian
34del version_info
35try:
36    _swig_property = property
37except NameError:
38    pass # Python < 2.2 doesn't have 'property'.
39def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
40    if (name == "thisown"): return self.this.own(value)
41    if (name == "this"):
42        if type(value).__name__ == 'SwigPyObject':
43            self.__dict__[name] = value
44            return
45    method = class_type.__swig_setmethods__.get(name,None)
46    if method: return method(self,value)
47    if (not static):
48        self.__dict__[name] = value
49    else:
50        raise AttributeError("You cannot add attributes to %s" % self)
51
52def _swig_setattr(self,class_type,name,value):
53    return _swig_setattr_nondynamic(self,class_type,name,value,0)
54
55def _swig_getattr(self,class_type,name):
56    if (name == "thisown"): return self.this.own()
57    method = class_type.__swig_getmethods__.get(name,None)
58    if method: return method(self)
59    raise AttributeError(name)
60
61def _swig_repr(self):
62    try: strthis = "proxy of " + self.this.__repr__()
63    except: strthis = ""
64    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
65
66try:
67    _object = object
68    _newclass = 1
69except AttributeError:
70    class _object : pass
71    _newclass = 0
72
73
74def _swig_setattr_nondynamic_method(set):
75    def set_attr(self,name,value):
76        if (name == "thisown"): return self.this.own(value)
77        if hasattr(self,name) or (name == "this"):
78            set(self,name,value)
79        else:
80            raise AttributeError("You cannot add attributes to %s" % self)
81    return set_attr
82
83
84try:
85    import weakref
86    weakref_proxy = weakref.proxy
87except:
88    weakref_proxy = lambda x: x
89
90
91class SwigPyIterator(object):
92    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
93    def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract")
94    __repr__ = _swig_repr
95    __swig_destroy__ = _xapian.delete_SwigPyIterator
96    def __iter__(self): return self
97SwigPyIterator.value = new_instancemethod(_xapian.SwigPyIterator_value,None,SwigPyIterator)
98SwigPyIterator.incr = new_instancemethod(_xapian.SwigPyIterator_incr,None,SwigPyIterator)
99SwigPyIterator.decr = new_instancemethod(_xapian.SwigPyIterator_decr,None,SwigPyIterator)
100SwigPyIterator.distance = new_instancemethod(_xapian.SwigPyIterator_distance,None,SwigPyIterator)
101SwigPyIterator.equal = new_instancemethod(_xapian.SwigPyIterator_equal,None,SwigPyIterator)
102SwigPyIterator.copy = new_instancemethod(_xapian.SwigPyIterator_copy,None,SwigPyIterator)
103SwigPyIterator.next = new_instancemethod(_xapian.SwigPyIterator_next,None,SwigPyIterator)
104SwigPyIterator.__next__ = new_instancemethod(_xapian.SwigPyIterator___next__,None,SwigPyIterator)
105SwigPyIterator.previous = new_instancemethod(_xapian.SwigPyIterator_previous,None,SwigPyIterator)
106SwigPyIterator.advance = new_instancemethod(_xapian.SwigPyIterator_advance,None,SwigPyIterator)
107SwigPyIterator.__eq__ = new_instancemethod(_xapian.SwigPyIterator___eq__,None,SwigPyIterator)
108SwigPyIterator.__ne__ = new_instancemethod(_xapian.SwigPyIterator___ne__,None,SwigPyIterator)
109SwigPyIterator.__iadd__ = new_instancemethod(_xapian.SwigPyIterator___iadd__,None,SwigPyIterator)
110SwigPyIterator.__isub__ = new_instancemethod(_xapian.SwigPyIterator___isub__,None,SwigPyIterator)
111SwigPyIterator.__add__ = new_instancemethod(_xapian.SwigPyIterator___add__,None,SwigPyIterator)
112SwigPyIterator.__sub__ = new_instancemethod(_xapian.SwigPyIterator___sub__,None,SwigPyIterator)
113SwigPyIterator_swigregister = _xapian.SwigPyIterator_swigregister
114SwigPyIterator_swigregister(SwigPyIterator)
115
116__version__ = '1.2.25'
117
118BAD_VALUENO = _xapian.BAD_VALUENO
119MSET_DID = _xapian.MSET_DID
120MSET_WT = _xapian.MSET_WT
121MSET_RANK = _xapian.MSET_RANK
122MSET_PERCENT = _xapian.MSET_PERCENT
123MSET_DOCUMENT = _xapian.MSET_DOCUMENT
124ESET_TNAME = _xapian.ESET_TNAME
125ESET_WT = _xapian.ESET_WT
126class Error(Exception):
127    """
128    All exceptions thrown by Xapian are subclasses of Xapian::Error.
129
130    This class can not be instantiated directly - instead a subclass
131    should be used.
132    """
133    __swig_setmethods__ = {}
134    __setattr__ = lambda self, name, value: _swig_setattr(self, Error, name, value)
135    __swig_getmethods__ = {}
136    __getattr__ = lambda self, name: _swig_getattr(self, Error, name)
137    def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
138    __repr__ = _swig_repr
139    def get_type(self):
140        """
141        The type of this error (e.g. "DocNotFoundError".)
142
143        const char* Xapian::Error::get_type() const
144        """
145        return _xapian.Error_get_type(self)
146
147    def get_msg(self):
148        """
149        Message giving details of the error, intended for human consumption.
150
151        const std::string& Xapian::Error::get_msg() const
152        """
153        return _xapian.Error_get_msg(self)
154
155    def get_context(self):
156        """
157        Optional context information.
158
159        const std::string& Xapian::Error::get_context() const
160
161        This context is intended for use by Xapian::ErrorHandler (for example
162        so it can know which remote server is unreliable and report the
163        problem and remove that server from those being searched). But it's
164        typically a plain-text string, and so also fit for human consumption.
165
166        """
167        return _xapian.Error_get_context(self)
168
169    def get_error_string(self):
170        """
171        Returns any system error string associated with this exception.
172
173        const char* Xapian::Error::get_error_string() const
174
175        The system error string may come from errno, h_errno (on UNIX), or
176        GetLastError() (on MS Windows). If there is no associated system error
177        string, NULL is returned.
178        """
179        return _xapian.Error_get_error_string(self)
180
181    __swig_destroy__ = _xapian.delete_Error
182Error.get_type = new_instancemethod(_xapian.Error_get_type,None,Error)
183Error.get_msg = new_instancemethod(_xapian.Error_get_msg,None,Error)
184Error.get_context = new_instancemethod(_xapian.Error_get_context,None,Error)
185Error.get_error_string = new_instancemethod(_xapian.Error_get_error_string,None,Error)
186Error.__str__ = new_instancemethod(_xapian.Error___str__,None,Error)
187Error_swigregister = _xapian.Error_swigregister
188Error_swigregister(Error)
189
190class LogicError(Error):
191    """
192    The base class for exceptions indicating errors in the program logic.
193
194    A subclass of LogicError will be thrown if Xapian detects a violation
195    of a class invariant or a logical precondition or postcondition, etc.
196
197    """
198    __swig_setmethods__ = {}
199    for _s in [Error]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
200    __setattr__ = lambda self, name, value: _swig_setattr(self, LogicError, name, value)
201    __swig_getmethods__ = {}
202    for _s in [Error]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
203    __getattr__ = lambda self, name: _swig_getattr(self, LogicError, name)
204    def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
205    __repr__ = _swig_repr
206    __swig_destroy__ = _xapian.delete_LogicError
207LogicError_swigregister = _xapian.LogicError_swigregister
208LogicError_swigregister(LogicError)
209
210class RuntimeError(Error):
211    """
212    The base class for exceptions indicating errors only detectable at
213    runtime.
214
215    A subclass of RuntimeError will be thrown if Xapian detects an error
216    which is exception derived from RuntimeError is thrown when an error
217    is caused by problems with the data or environment rather than a
218    programming mistake.
219    """
220    __swig_setmethods__ = {}
221    for _s in [Error]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
222    __setattr__ = lambda self, name, value: _swig_setattr(self, RuntimeError, name, value)
223    __swig_getmethods__ = {}
224    for _s in [Error]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
225    __getattr__ = lambda self, name: _swig_getattr(self, RuntimeError, name)
226    def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
227    __repr__ = _swig_repr
228    __swig_destroy__ = _xapian.delete_RuntimeError
229RuntimeError_swigregister = _xapian.RuntimeError_swigregister
230RuntimeError_swigregister(RuntimeError)
231
232class AssertionError(LogicError):
233    """
234    AssertionError is thrown if a logical assertion inside Xapian fails.
235
236    In a debug build of Xapian, a failed assertion in the core library
237    code will cause AssertionError to be thrown.
238
239    This represents a bug in Xapian (either an invariant, precondition,
240    etc has been violated, or the assertion is incorrect!)
241    """
242    __swig_setmethods__ = {}
243    for _s in [LogicError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
244    __setattr__ = lambda self, name, value: _swig_setattr(self, AssertionError, name, value)
245    __swig_getmethods__ = {}
246    for _s in [LogicError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
247    __getattr__ = lambda self, name: _swig_getattr(self, AssertionError, name)
248    __repr__ = _swig_repr
249    def __init__(self, *args):
250        """
251        Construct from message and errno value.
252
253        Xapian::AssertionError::AssertionError(const std::string &msg_, int
254        errno_)
255
256        Parameters:
257        -----------
258
259        msg_:  Message giving details of the error, intended for human
260        consumption.
261
262        errno_:  Optional errno value associated with this error.
263        """
264        _xapian.AssertionError_swiginit(self,_xapian.new_AssertionError(*args))
265    __swig_destroy__ = _xapian.delete_AssertionError
266AssertionError_swigregister = _xapian.AssertionError_swigregister
267AssertionError_swigregister(AssertionError)
268
269class InvalidArgumentError(LogicError):
270    """
271    InvalidArgumentError indicates an invalid parameter value was passed
272    to the API.
273    """
274    __swig_setmethods__ = {}
275    for _s in [LogicError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
276    __setattr__ = lambda self, name, value: _swig_setattr(self, InvalidArgumentError, name, value)
277    __swig_getmethods__ = {}
278    for _s in [LogicError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
279    __getattr__ = lambda self, name: _swig_getattr(self, InvalidArgumentError, name)
280    __repr__ = _swig_repr
281    def __init__(self, *args):
282        """
283        Construct from message and errno value.
284
285        Xapian::InvalidArgumentError::InvalidArgumentError(const std::string
286        &msg_, int errno_)
287
288        Parameters:
289        -----------
290
291        msg_:  Message giving details of the error, intended for human
292        consumption.
293
294        errno_:  Optional errno value associated with this error.
295        """
296        _xapian.InvalidArgumentError_swiginit(self,_xapian.new_InvalidArgumentError(*args))
297    __swig_destroy__ = _xapian.delete_InvalidArgumentError
298InvalidArgumentError_swigregister = _xapian.InvalidArgumentError_swigregister
299InvalidArgumentError_swigregister(InvalidArgumentError)
300
301class InvalidOperationError(LogicError):
302    """
303    InvalidOperationError indicates the API was used in an invalid way.
304    """
305    __swig_setmethods__ = {}
306    for _s in [LogicError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
307    __setattr__ = lambda self, name, value: _swig_setattr(self, InvalidOperationError, name, value)
308    __swig_getmethods__ = {}
309    for _s in [LogicError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
310    __getattr__ = lambda self, name: _swig_getattr(self, InvalidOperationError, name)
311    __repr__ = _swig_repr
312    def __init__(self, *args):
313        """
314        Construct from message and errno value.
315
316        Xapian::InvalidOperationError::InvalidOperationError(const std::string
317        &msg_, int errno_)
318
319        Parameters:
320        -----------
321
322        msg_:  Message giving details of the error, intended for human
323        consumption.
324
325        errno_:  Optional errno value associated with this error.
326        """
327        _xapian.InvalidOperationError_swiginit(self,_xapian.new_InvalidOperationError(*args))
328    __swig_destroy__ = _xapian.delete_InvalidOperationError
329InvalidOperationError_swigregister = _xapian.InvalidOperationError_swigregister
330InvalidOperationError_swigregister(InvalidOperationError)
331
332class UnimplementedError(LogicError):
333    """
334    UnimplementedError indicates an attempt to use an unimplemented
335    feature.
336    """
337    __swig_setmethods__ = {}
338    for _s in [LogicError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
339    __setattr__ = lambda self, name, value: _swig_setattr(self, UnimplementedError, name, value)
340    __swig_getmethods__ = {}
341    for _s in [LogicError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
342    __getattr__ = lambda self, name: _swig_getattr(self, UnimplementedError, name)
343    __repr__ = _swig_repr
344    def __init__(self, *args):
345        """
346        Construct from message and errno value.
347
348        Xapian::UnimplementedError::UnimplementedError(const std::string
349        &msg_, int errno_)
350
351        Parameters:
352        -----------
353
354        msg_:  Message giving details of the error, intended for human
355        consumption.
356
357        errno_:  Optional errno value associated with this error.
358        """
359        _xapian.UnimplementedError_swiginit(self,_xapian.new_UnimplementedError(*args))
360    __swig_destroy__ = _xapian.delete_UnimplementedError
361UnimplementedError_swigregister = _xapian.UnimplementedError_swigregister
362UnimplementedError_swigregister(UnimplementedError)
363
364class DatabaseError(RuntimeError):
365    """
366    DatabaseError indicates some sort of database related error.
367    """
368    __swig_setmethods__ = {}
369    for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
370    __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseError, name, value)
371    __swig_getmethods__ = {}
372    for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
373    __getattr__ = lambda self, name: _swig_getattr(self, DatabaseError, name)
374    __repr__ = _swig_repr
375    def __init__(self, *args):
376        """
377        Construct from message and errno value.
378
379        Xapian::DatabaseError::DatabaseError(const std::string &msg_, int
380        errno_)
381
382        Parameters:
383        -----------
384
385        msg_:  Message giving details of the error, intended for human
386        consumption.
387
388        errno_:  Optional errno value associated with this error.
389        """
390        _xapian.DatabaseError_swiginit(self,_xapian.new_DatabaseError(*args))
391    __swig_destroy__ = _xapian.delete_DatabaseError
392DatabaseError_swigregister = _xapian.DatabaseError_swigregister
393DatabaseError_swigregister(DatabaseError)
394
395class DatabaseCorruptError(DatabaseError):
396    """
397    DatabaseCorruptError indicates database corruption was detected.
398    """
399    __swig_setmethods__ = {}
400    for _s in [DatabaseError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
401    __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseCorruptError, name, value)
402    __swig_getmethods__ = {}
403    for _s in [DatabaseError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
404    __getattr__ = lambda self, name: _swig_getattr(self, DatabaseCorruptError, name)
405    __repr__ = _swig_repr
406    def __init__(self, *args):
407        """
408        Construct from message and errno value.
409
410        Xapian::DatabaseCorruptError::DatabaseCorruptError(const std::string
411        &msg_, int errno_)
412
413        Parameters:
414        -----------
415
416        msg_:  Message giving details of the error, intended for human
417        consumption.
418
419        errno_:  Optional errno value associated with this error.
420        """
421        _xapian.DatabaseCorruptError_swiginit(self,_xapian.new_DatabaseCorruptError(*args))
422    __swig_destroy__ = _xapian.delete_DatabaseCorruptError
423DatabaseCorruptError_swigregister = _xapian.DatabaseCorruptError_swigregister
424DatabaseCorruptError_swigregister(DatabaseCorruptError)
425
426class DatabaseCreateError(DatabaseError):
427    """
428    DatabaseCreateError indicates a failure to create a database.
429    """
430    __swig_setmethods__ = {}
431    for _s in [DatabaseError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
432    __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseCreateError, name, value)
433    __swig_getmethods__ = {}
434    for _s in [DatabaseError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
435    __getattr__ = lambda self, name: _swig_getattr(self, DatabaseCreateError, name)
436    __repr__ = _swig_repr
437    def __init__(self, *args):
438        """
439        Construct from message and errno value.
440
441        Xapian::DatabaseCreateError::DatabaseCreateError(const std::string
442        &msg_, int errno_)
443
444        Parameters:
445        -----------
446
447        msg_:  Message giving details of the error, intended for human
448        consumption.
449
450        errno_:  Optional errno value associated with this error.
451        """
452        _xapian.DatabaseCreateError_swiginit(self,_xapian.new_DatabaseCreateError(*args))
453    __swig_destroy__ = _xapian.delete_DatabaseCreateError
454DatabaseCreateError_swigregister = _xapian.DatabaseCreateError_swigregister
455DatabaseCreateError_swigregister(DatabaseCreateError)
456
457class DatabaseLockError(DatabaseError):
458    """
459    DatabaseLockError indicates failure to lock a database.
460    """
461    __swig_setmethods__ = {}
462    for _s in [DatabaseError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
463    __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseLockError, name, value)
464    __swig_getmethods__ = {}
465    for _s in [DatabaseError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
466    __getattr__ = lambda self, name: _swig_getattr(self, DatabaseLockError, name)
467    __repr__ = _swig_repr
468    def __init__(self, *args):
469        """
470        Construct from message and errno value.
471
472        Xapian::DatabaseLockError::DatabaseLockError(const std::string &msg_,
473        int errno_)
474
475        Parameters:
476        -----------
477
478        msg_:  Message giving details of the error, intended for human
479        consumption.
480
481        errno_:  Optional errno value associated with this error.
482        """
483        _xapian.DatabaseLockError_swiginit(self,_xapian.new_DatabaseLockError(*args))
484    __swig_destroy__ = _xapian.delete_DatabaseLockError
485DatabaseLockError_swigregister = _xapian.DatabaseLockError_swigregister
486DatabaseLockError_swigregister(DatabaseLockError)
487
488class DatabaseModifiedError(DatabaseError):
489    """
490    DatabaseModifiedError indicates a database was modified.
491
492    To recover after catching this error, you need to call
493    Xapian::Database::reopen() on the Database and repeat the operation
494    which failed.
495    """
496    __swig_setmethods__ = {}
497    for _s in [DatabaseError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
498    __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseModifiedError, name, value)
499    __swig_getmethods__ = {}
500    for _s in [DatabaseError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
501    __getattr__ = lambda self, name: _swig_getattr(self, DatabaseModifiedError, name)
502    __repr__ = _swig_repr
503    def __init__(self, *args):
504        """
505        Construct from message and errno value.
506
507        Xapian::DatabaseModifiedError::DatabaseModifiedError(const std::string
508        &msg_, int errno_)
509
510        Parameters:
511        -----------
512
513        msg_:  Message giving details of the error, intended for human
514        consumption.
515
516        errno_:  Optional errno value associated with this error.
517        """
518        _xapian.DatabaseModifiedError_swiginit(self,_xapian.new_DatabaseModifiedError(*args))
519    __swig_destroy__ = _xapian.delete_DatabaseModifiedError
520DatabaseModifiedError_swigregister = _xapian.DatabaseModifiedError_swigregister
521DatabaseModifiedError_swigregister(DatabaseModifiedError)
522
523class DatabaseOpeningError(DatabaseError):
524    """
525    DatabaseOpeningError indicates failure to open a database.
526    """
527    __swig_setmethods__ = {}
528    for _s in [DatabaseError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
529    __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseOpeningError, name, value)
530    __swig_getmethods__ = {}
531    for _s in [DatabaseError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
532    __getattr__ = lambda self, name: _swig_getattr(self, DatabaseOpeningError, name)
533    __repr__ = _swig_repr
534    def __init__(self, *args):
535        """
536        Construct from message and errno value.
537
538        Xapian::DatabaseOpeningError::DatabaseOpeningError(const std::string
539        &msg_, int errno_)
540
541        Parameters:
542        -----------
543
544        msg_:  Message giving details of the error, intended for human
545        consumption.
546
547        errno_:  Optional errno value associated with this error.
548        """
549        _xapian.DatabaseOpeningError_swiginit(self,_xapian.new_DatabaseOpeningError(*args))
550    __swig_destroy__ = _xapian.delete_DatabaseOpeningError
551DatabaseOpeningError_swigregister = _xapian.DatabaseOpeningError_swigregister
552DatabaseOpeningError_swigregister(DatabaseOpeningError)
553
554class DatabaseVersionError(DatabaseOpeningError):
555    """
556    DatabaseVersionError indicates that a database is in an unsupported
557    format.
558
559    From time to time, new versions of Xapian will require the database
560    format to be changed, to allow new information to be stored or new
561    optimisations to be performed. Backwards compatibility will sometimes
562    be maintained, so that new versions of Xapian can open old databases,
563    but in some cases Xapian will be unable to open a database because it
564    is in too old (or new) a format. This can be resolved either be
565    upgrading or downgrading the version of Xapian in use, or by
566    rebuilding the database from scratch with the current version of
567    Xapian.
568    """
569    __swig_setmethods__ = {}
570    for _s in [DatabaseOpeningError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
571    __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseVersionError, name, value)
572    __swig_getmethods__ = {}
573    for _s in [DatabaseOpeningError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
574    __getattr__ = lambda self, name: _swig_getattr(self, DatabaseVersionError, name)
575    __repr__ = _swig_repr
576    def __init__(self, *args):
577        """
578        Construct from message and errno value.
579
580        Xapian::DatabaseVersionError::DatabaseVersionError(const std::string
581        &msg_, int errno_)
582
583        Parameters:
584        -----------
585
586        msg_:  Message giving details of the error, intended for human
587        consumption.
588
589        errno_:  Optional errno value associated with this error.
590        """
591        _xapian.DatabaseVersionError_swiginit(self,_xapian.new_DatabaseVersionError(*args))
592    __swig_destroy__ = _xapian.delete_DatabaseVersionError
593DatabaseVersionError_swigregister = _xapian.DatabaseVersionError_swigregister
594DatabaseVersionError_swigregister(DatabaseVersionError)
595
596class DocNotFoundError(RuntimeError):
597    """
598    Indicates an attempt to access a document not present in the database.
599
600    """
601    __swig_setmethods__ = {}
602    for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
603    __setattr__ = lambda self, name, value: _swig_setattr(self, DocNotFoundError, name, value)
604    __swig_getmethods__ = {}
605    for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
606    __getattr__ = lambda self, name: _swig_getattr(self, DocNotFoundError, name)
607    __repr__ = _swig_repr
608    def __init__(self, *args):
609        """
610        Construct from message and errno value.
611
612        Xapian::DocNotFoundError::DocNotFoundError(const std::string &msg_,
613        int errno_)
614
615        Parameters:
616        -----------
617
618        msg_:  Message giving details of the error, intended for human
619        consumption.
620
621        errno_:  Optional errno value associated with this error.
622        """
623        _xapian.DocNotFoundError_swiginit(self,_xapian.new_DocNotFoundError(*args))
624    __swig_destroy__ = _xapian.delete_DocNotFoundError
625DocNotFoundError_swigregister = _xapian.DocNotFoundError_swigregister
626DocNotFoundError_swigregister(DocNotFoundError)
627
628class FeatureUnavailableError(RuntimeError):
629    """
630    Indicates an attempt to use a feature which is unavailable.
631
632    Typically a feature is unavailable because it wasn't compiled in, or
633    because it requires other software or facilities which aren't
634    available.
635    """
636    __swig_setmethods__ = {}
637    for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
638    __setattr__ = lambda self, name, value: _swig_setattr(self, FeatureUnavailableError, name, value)
639    __swig_getmethods__ = {}
640    for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
641    __getattr__ = lambda self, name: _swig_getattr(self, FeatureUnavailableError, name)
642    __repr__ = _swig_repr
643    def __init__(self, *args):
644        """
645        Construct from message and errno value.
646
647        Xapian::FeatureUnavailableError::FeatureUnavailableError(const
648        std::string &msg_, int errno_)
649
650        Parameters:
651        -----------
652
653        msg_:  Message giving details of the error, intended for human
654        consumption.
655
656        errno_:  Optional errno value associated with this error.
657        """
658        _xapian.FeatureUnavailableError_swiginit(self,_xapian.new_FeatureUnavailableError(*args))
659    __swig_destroy__ = _xapian.delete_FeatureUnavailableError
660FeatureUnavailableError_swigregister = _xapian.FeatureUnavailableError_swigregister
661FeatureUnavailableError_swigregister(FeatureUnavailableError)
662
663class InternalError(RuntimeError):
664    """
665    InternalError indicates a runtime problem of some sort.
666    """
667    __swig_setmethods__ = {}
668    for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
669    __setattr__ = lambda self, name, value: _swig_setattr(self, InternalError, name, value)
670    __swig_getmethods__ = {}
671    for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
672    __getattr__ = lambda self, name: _swig_getattr(self, InternalError, name)
673    __repr__ = _swig_repr
674    def __init__(self, *args):
675        """
676        Construct from message and errno value.
677
678        Xapian::InternalError::InternalError(const std::string &msg_, int
679        errno_)
680
681        Parameters:
682        -----------
683
684        msg_:  Message giving details of the error, intended for human
685        consumption.
686
687        errno_:  Optional errno value associated with this error.
688        """
689        _xapian.InternalError_swiginit(self,_xapian.new_InternalError(*args))
690    __swig_destroy__ = _xapian.delete_InternalError
691InternalError_swigregister = _xapian.InternalError_swigregister
692InternalError_swigregister(InternalError)
693
694class NetworkError(RuntimeError):
695    """
696    Indicates a problem communicating with a remote database.
697    """
698    __swig_setmethods__ = {}
699    for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
700    __setattr__ = lambda self, name, value: _swig_setattr(self, NetworkError, name, value)
701    __swig_getmethods__ = {}
702    for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
703    __getattr__ = lambda self, name: _swig_getattr(self, NetworkError, name)
704    __repr__ = _swig_repr
705    def __init__(self, *args):
706        """
707        Construct from message and errno value.
708
709        Xapian::NetworkError::NetworkError(const std::string &msg_, int
710        errno_)
711
712        Parameters:
713        -----------
714
715        msg_:  Message giving details of the error, intended for human
716        consumption.
717
718        errno_:  Optional errno value associated with this error.
719        """
720        _xapian.NetworkError_swiginit(self,_xapian.new_NetworkError(*args))
721    __swig_destroy__ = _xapian.delete_NetworkError
722NetworkError_swigregister = _xapian.NetworkError_swigregister
723NetworkError_swigregister(NetworkError)
724
725class NetworkTimeoutError(NetworkError):
726    """
727    Indicates a timeout expired while communicating with a remote
728    database.
729    """
730    __swig_setmethods__ = {}
731    for _s in [NetworkError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
732    __setattr__ = lambda self, name, value: _swig_setattr(self, NetworkTimeoutError, name, value)
733    __swig_getmethods__ = {}
734    for _s in [NetworkError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
735    __getattr__ = lambda self, name: _swig_getattr(self, NetworkTimeoutError, name)
736    __repr__ = _swig_repr
737    def __init__(self, *args):
738        """
739        Construct from message and errno value.
740
741        Xapian::NetworkTimeoutError::NetworkTimeoutError(const std::string
742        &msg_, int errno_)
743
744        Parameters:
745        -----------
746
747        msg_:  Message giving details of the error, intended for human
748        consumption.
749
750        errno_:  Optional errno value associated with this error.
751        """
752        _xapian.NetworkTimeoutError_swiginit(self,_xapian.new_NetworkTimeoutError(*args))
753    __swig_destroy__ = _xapian.delete_NetworkTimeoutError
754NetworkTimeoutError_swigregister = _xapian.NetworkTimeoutError_swigregister
755NetworkTimeoutError_swigregister(NetworkTimeoutError)
756
757class QueryParserError(RuntimeError):
758    """
759    Indicates a query string can't be parsed.
760    """
761    __swig_setmethods__ = {}
762    for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
763    __setattr__ = lambda self, name, value: _swig_setattr(self, QueryParserError, name, value)
764    __swig_getmethods__ = {}
765    for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
766    __getattr__ = lambda self, name: _swig_getattr(self, QueryParserError, name)
767    __repr__ = _swig_repr
768    def __init__(self, *args):
769        """
770        Construct from message and errno value.
771
772        Xapian::QueryParserError::QueryParserError(const std::string &msg_,
773        int errno_)
774
775        Parameters:
776        -----------
777
778        msg_:  Message giving details of the error, intended for human
779        consumption.
780
781        errno_:  Optional errno value associated with this error.
782        """
783        _xapian.QueryParserError_swiginit(self,_xapian.new_QueryParserError(*args))
784    __swig_destroy__ = _xapian.delete_QueryParserError
785QueryParserError_swigregister = _xapian.QueryParserError_swigregister
786QueryParserError_swigregister(QueryParserError)
787
788class SerialisationError(RuntimeError):
789    """
790    Indicates an error in the std::string serialisation of an object.
791    """
792    __swig_setmethods__ = {}
793    for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
794    __setattr__ = lambda self, name, value: _swig_setattr(self, SerialisationError, name, value)
795    __swig_getmethods__ = {}
796    for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
797    __getattr__ = lambda self, name: _swig_getattr(self, SerialisationError, name)
798    __repr__ = _swig_repr
799    def __init__(self, *args):
800        """
801        Construct from message and errno value.
802
803        Xapian::SerialisationError::SerialisationError(const std::string
804        &msg_, int errno_)
805
806        Parameters:
807        -----------
808
809        msg_:  Message giving details of the error, intended for human
810        consumption.
811
812        errno_:  Optional errno value associated with this error.
813        """
814        _xapian.SerialisationError_swiginit(self,_xapian.new_SerialisationError(*args))
815    __swig_destroy__ = _xapian.delete_SerialisationError
816SerialisationError_swigregister = _xapian.SerialisationError_swigregister
817SerialisationError_swigregister(SerialisationError)
818
819class RangeError(RuntimeError):
820    """
821    RangeError indicates an attempt to access outside the bounds of a
822    container.
823    """
824    __swig_setmethods__ = {}
825    for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
826    __setattr__ = lambda self, name, value: _swig_setattr(self, RangeError, name, value)
827    __swig_getmethods__ = {}
828    for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
829    __getattr__ = lambda self, name: _swig_getattr(self, RangeError, name)
830    __repr__ = _swig_repr
831    def __init__(self, *args):
832        """
833        Construct from message and errno value.
834
835        Xapian::RangeError::RangeError(const std::string &msg_, int errno_)
836
837        Parameters:
838        -----------
839
840        msg_:  Message giving details of the error, intended for human
841        consumption.
842
843        errno_:  Optional errno value associated with this error.
844        """
845        _xapian.RangeError_swiginit(self,_xapian.new_RangeError(*args))
846    __swig_destroy__ = _xapian.delete_RangeError
847RangeError_swigregister = _xapian.RangeError_swigregister
848RangeError_swigregister(RangeError)
849
850
851def version_string():
852  return _xapian.version_string()
853version_string = _xapian.version_string
854
855def major_version():
856  return _xapian.major_version()
857major_version = _xapian.major_version
858
859def minor_version():
860  return _xapian.minor_version()
861minor_version = _xapian.minor_version
862
863def revision():
864  return _xapian.revision()
865revision = _xapian.revision
866class PositionIterator(object):
867    """
868    An iterator pointing to items in a list of positions.
869    """
870    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
871    __repr__ = _swig_repr
872    def __init__(self, *args):
873        """
874        Copying is allowed.
875
876        Xapian::PositionIterator::PositionIterator(const PositionIterator &o)
877
878        The internals are reference counted, so copying is also cheap.
879        """
880        _xapian.PositionIterator_swiginit(self,_xapian.new_PositionIterator(*args))
881    __swig_destroy__ = _xapian.delete_PositionIterator
882    def skip_to(self, *args):
883        """
884        Advance the iterator to the specified termpos.
885
886        void Xapian::PositionIterator::skip_to(Xapian::termpos pos)
887
888        If the specified termpos isn't in the list, position ourselves on the
889        first termpos after it (or at_end() if no greater term positions are
890        present).
891        """
892        return _xapian.PositionIterator_skip_to(self, *args)
893
894    def __str__(self):
895        """
896        Return a string describing this object.
897
898        std::string Xapian::PositionIterator::get_description() const
899        """
900        return _xapian.PositionIterator___str__(self)
901
902PositionIterator.get_termpos = new_instancemethod(_xapian.PositionIterator_get_termpos,None,PositionIterator)
903PositionIterator.next = new_instancemethod(_xapian.PositionIterator_next,None,PositionIterator)
904PositionIterator.equals = new_instancemethod(_xapian.PositionIterator_equals,None,PositionIterator)
905PositionIterator.skip_to = new_instancemethod(_xapian.PositionIterator_skip_to,None,PositionIterator)
906PositionIterator.__str__ = new_instancemethod(_xapian.PositionIterator___str__,None,PositionIterator)
907PositionIterator.__eq__ = new_instancemethod(_xapian.PositionIterator___eq__,None,PositionIterator)
908PositionIterator.__ne__ = new_instancemethod(_xapian.PositionIterator___ne__,None,PositionIterator)
909PositionIterator_swigregister = _xapian.PositionIterator_swigregister
910PositionIterator_swigregister(PositionIterator)
911
912class PostingIterator(object):
913    """
914    An iterator pointing to items in a list of postings.
915    """
916    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
917    __repr__ = _swig_repr
918    __swig_destroy__ = _xapian.delete_PostingIterator
919    def __init__(self, *args):
920        """
921        Copying is allowed.
922
923        Xapian::PostingIterator::PostingIterator(const PostingIterator &other)
924
925        The internals are reference counted, so copying is also cheap.
926        """
927        _xapian.PostingIterator_swiginit(self,_xapian.new_PostingIterator(*args))
928    def skip_to(self, *args):
929        """
930        Advance the iterator to the specified docid.
931
932        void Xapian::PostingIterator::skip_to(Xapian::docid did)
933
934        If the specified docid isn't in the list, position ourselves on the
935        first document after it (or at_end() if no greater docids are
936        present).
937        """
938        return _xapian.PostingIterator_skip_to(self, *args)
939
940    def get_doclength(self):
941        """
942        Get the length of the document at the current position in the
943        postlist.
944
945        Xapian::termcount Xapian::PostingIterator::get_doclength() const
946
947        This information may be stored in the postlist, in which case this
948        lookup should be extremely fast (indeed, not require further disk
949        access). If the information is not present in the postlist, it will be
950        retrieved from the database, at a greater performance cost.
951        """
952        return _xapian.PostingIterator_get_doclength(self)
953
954    def get_wdf(self):
955        """
956        Get the within document frequency of the document at the current
957        position in the postlist.
958
959        Xapian::termcount Xapian::PostingIterator::get_wdf() const
960        """
961        return _xapian.PostingIterator_get_wdf(self)
962
963    def positionlist_begin(self):
964        """
965        Return PositionIterator pointing to start of positionlist for current
966        document.
967
968        PositionIterator Xapian::PostingIterator::positionlist_begin() const
969
970        """
971        return _xapian.PostingIterator_positionlist_begin(self)
972
973    def positionlist_end(self):
974        """
975        Return PositionIterator pointing to end of positionlist for current
976        document.
977
978        PositionIterator Xapian::PostingIterator::positionlist_end() const
979        """
980        return _xapian.PostingIterator_positionlist_end(self)
981
982    def __str__(self):
983        """
984        Return a string describing this object.
985
986        std::string Xapian::PostingIterator::get_description() const
987        """
988        return _xapian.PostingIterator___str__(self)
989
990PostingIterator.skip_to = new_instancemethod(_xapian.PostingIterator_skip_to,None,PostingIterator)
991PostingIterator.get_doclength = new_instancemethod(_xapian.PostingIterator_get_doclength,None,PostingIterator)
992PostingIterator.get_wdf = new_instancemethod(_xapian.PostingIterator_get_wdf,None,PostingIterator)
993PostingIterator.positionlist_begin = new_instancemethod(_xapian.PostingIterator_positionlist_begin,None,PostingIterator)
994PostingIterator.positionlist_end = new_instancemethod(_xapian.PostingIterator_positionlist_end,None,PostingIterator)
995PostingIterator.__str__ = new_instancemethod(_xapian.PostingIterator___str__,None,PostingIterator)
996PostingIterator.__eq__ = new_instancemethod(_xapian.PostingIterator___eq__,None,PostingIterator)
997PostingIterator.__ne__ = new_instancemethod(_xapian.PostingIterator___ne__,None,PostingIterator)
998PostingIterator.get_docid = new_instancemethod(_xapian.PostingIterator_get_docid,None,PostingIterator)
999PostingIterator.next = new_instancemethod(_xapian.PostingIterator_next,None,PostingIterator)
1000PostingIterator.equals = new_instancemethod(_xapian.PostingIterator_equals,None,PostingIterator)
1001PostingIterator_swigregister = _xapian.PostingIterator_swigregister
1002PostingIterator_swigregister(PostingIterator)
1003
1004
1005def __eq__(*args):
1006  return _xapian.__eq__(*args)
1007__eq__ = _xapian.__eq__
1008
1009def __ne__(*args):
1010  return _xapian.__ne__(*args)
1011__ne__ = _xapian.__ne__
1012class TermIterator(object):
1013    """
1014    An iterator pointing to items in a list of terms.
1015    """
1016    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
1017    __repr__ = _swig_repr
1018    def __init__(self, *args):
1019        """
1020        Copying is allowed.
1021
1022        Xapian::TermIterator::TermIterator(const TermIterator &other)
1023
1024        The internals are reference counted, so copying is also cheap.
1025        """
1026        _xapian.TermIterator_swiginit(self,_xapian.new_TermIterator(*args))
1027    __swig_destroy__ = _xapian.delete_TermIterator
1028    def skip_to(self, *args):
1029        """
1030        Advance the iterator to the specified term.
1031
1032        void Xapian::TermIterator::skip_to(const std::string &tname)
1033
1034        If the specified term isn't in the list, position ourselves on the
1035        first term after it (or at_end() if no greater terms are present).
1036        """
1037        return _xapian.TermIterator_skip_to(self, *args)
1038
1039    def get_wdf(self):
1040        """
1041        Return the wdf of the current term (if meaningful).
1042
1043        Xapian::termcount Xapian::TermIterator::get_wdf() const
1044
1045        The wdf (within document frequency) is the number of occurrences of a
1046        term in a particular document.
1047        """
1048        return _xapian.TermIterator_get_wdf(self)
1049
1050    def get_termfreq(self):
1051        """
1052        Return the term frequency of the current term (if meaningful).
1053
1054        Xapian::doccount Xapian::TermIterator::get_termfreq() const
1055
1056        The term frequency is the number of documents which a term indexes.
1057        """
1058        return _xapian.TermIterator_get_termfreq(self)
1059
1060    def positionlist_count(self):
1061        """
1062        Return length of positionlist for current term.
1063
1064        Xapian::termcount Xapian::TermIterator::positionlist_count() const
1065        """
1066        return _xapian.TermIterator_positionlist_count(self)
1067
1068    def positionlist_begin(self):
1069        """
1070        Return PositionIterator pointing to start of positionlist for current
1071        term.
1072
1073        PositionIterator Xapian::TermIterator::positionlist_begin() const
1074        """
1075        return _xapian.TermIterator_positionlist_begin(self)
1076
1077    def positionlist_end(self):
1078        """
1079        Return PositionIterator pointing to end of positionlist for current
1080        term.
1081
1082        PositionIterator Xapian::TermIterator::positionlist_end() const
1083        """
1084        return _xapian.TermIterator_positionlist_end(self)
1085
1086    def __str__(self):
1087        """
1088        Return a string describing this object.
1089
1090        std::string Xapian::TermIterator::get_description() const
1091        """
1092        return _xapian.TermIterator___str__(self)
1093
1094TermIterator.get_term = new_instancemethod(_xapian.TermIterator_get_term,None,TermIterator)
1095TermIterator.next = new_instancemethod(_xapian.TermIterator_next,None,TermIterator)
1096TermIterator.equals = new_instancemethod(_xapian.TermIterator_equals,None,TermIterator)
1097TermIterator.skip_to = new_instancemethod(_xapian.TermIterator_skip_to,None,TermIterator)
1098TermIterator.get_wdf = new_instancemethod(_xapian.TermIterator_get_wdf,None,TermIterator)
1099TermIterator.get_termfreq = new_instancemethod(_xapian.TermIterator_get_termfreq,None,TermIterator)
1100TermIterator.positionlist_count = new_instancemethod(_xapian.TermIterator_positionlist_count,None,TermIterator)
1101TermIterator.positionlist_begin = new_instancemethod(_xapian.TermIterator_positionlist_begin,None,TermIterator)
1102TermIterator.positionlist_end = new_instancemethod(_xapian.TermIterator_positionlist_end,None,TermIterator)
1103TermIterator.__str__ = new_instancemethod(_xapian.TermIterator___str__,None,TermIterator)
1104TermIterator.__eq__ = new_instancemethod(_xapian.TermIterator___eq__,None,TermIterator)
1105TermIterator.__ne__ = new_instancemethod(_xapian.TermIterator___ne__,None,TermIterator)
1106TermIterator_swigregister = _xapian.TermIterator_swigregister
1107TermIterator_swigregister(TermIterator)
1108
1109class ValueIterator(object):
1110    """
1111    Class for iterating over document values.
1112    """
1113    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
1114    __repr__ = _swig_repr
1115    def __init__(self, *args):
1116        """
1117        Default constructor.
1118
1119        Xapian::ValueIterator::ValueIterator()
1120
1121        Creates an uninitialised iterator, which can't be used before being
1122        assigned to, but is sometimes syntactically convenient.
1123        """
1124        _xapian.ValueIterator_swiginit(self,_xapian.new_ValueIterator(*args))
1125    __swig_destroy__ = _xapian.delete_ValueIterator
1126    def get_docid(self):
1127        """
1128        Return the docid at the current position.
1129
1130        Xapian::docid Xapian::ValueIterator::get_docid() const
1131
1132        If we're iterating over values of a document, this method will throw
1133        Xapian::InvalidOperationError.
1134        """
1135        return _xapian.ValueIterator_get_docid(self)
1136
1137    def get_valueno(self):
1138        """
1139        Return the value slot number for the current position.
1140
1141        Xapian::valueno Xapian::ValueIterator::get_valueno() const
1142
1143        If the iterator is over all values in a slot, this returns that slot's
1144        number. If the iterator is over the values in a particular document,
1145        it returns the number of each slot in turn.
1146        """
1147        return _xapian.ValueIterator_get_valueno(self)
1148
1149    def skip_to(self, *args):
1150        """
1151        Advance the iterator to document id or value slot docid_or_slot.
1152
1153        void Xapian::ValueIterator::skip_to(Xapian::docid docid_or_slot)
1154
1155        If this iterator is over values in a document, then this method
1156        advances the iterator to value slot docid_or_slot, or the first slot
1157        after it if there is no value in slot slot.
1158
1159        If this iterator is over values in a particular slot, then this method
1160        advances the iterator to document id docid_or_slot, or the first
1161        document id after it if there is no value in the slot we're iterating
1162        over for document docid_or_slot.
1163
1164        Note: The "two-faced" nature of this method is due to how C++
1165        overloading works. Xapian::docid and Xapian::valueno are both typedefs
1166        for the same unsigned integer type, so overloading can't distinguish
1167        them.
1168
1169        Parameters:
1170        -----------
1171
1172        docid_or_slot:  The docid/slot to advance to.
1173        """
1174        return _xapian.ValueIterator_skip_to(self, *args)
1175
1176    def check(self, *args):
1177        """
1178        Check if the specified docid occurs.
1179
1180        bool Xapian::ValueIterator::check(Xapian::docid docid)
1181
1182        The caller is required to ensure that the specified document id did
1183        actually exists in the database.
1184
1185        This method acts like skip_to() if that can be done at little extra
1186        cost, in which case it then returns true. This is how brass and chert
1187        databases behave because they store values in streams which allow for
1188        an efficient implementation of skip_to().
1189
1190        Otherwise it simply checks if a particular docid is present. If it is,
1191        it returns true. If it isn't, it returns false, and leaves the
1192        position unspecified (and hence the result of calling methods which
1193        depends on the current position, such as get_docid(), are also
1194        unspecified). In this state, next() will advance to the first matching
1195        position after document did, and skip_to() will act as it would if the
1196        position was the first matching position after document did.
1197
1198        Currently the inmemory, flint, and remote backends behave in the
1199        latter way because they don't support streamed values and so skip_to()
1200        must check each document it skips over which is significantly slower.
1201
1202        Parameters:
1203        -----------
1204
1205        docid:  The document id to check.
1206        """
1207        return _xapian.ValueIterator_check(self, *args)
1208
1209    def __str__(self):
1210        """
1211        Return a string describing this object.
1212
1213        std::string Xapian::ValueIterator::get_description() const
1214        """
1215        return _xapian.ValueIterator___str__(self)
1216
1217ValueIterator.get_value = new_instancemethod(_xapian.ValueIterator_get_value,None,ValueIterator)
1218ValueIterator.next = new_instancemethod(_xapian.ValueIterator_next,None,ValueIterator)
1219ValueIterator.equals = new_instancemethod(_xapian.ValueIterator_equals,None,ValueIterator)
1220ValueIterator.get_docid = new_instancemethod(_xapian.ValueIterator_get_docid,None,ValueIterator)
1221ValueIterator.get_valueno = new_instancemethod(_xapian.ValueIterator_get_valueno,None,ValueIterator)
1222ValueIterator.skip_to = new_instancemethod(_xapian.ValueIterator_skip_to,None,ValueIterator)
1223ValueIterator.check = new_instancemethod(_xapian.ValueIterator_check,None,ValueIterator)
1224ValueIterator.__str__ = new_instancemethod(_xapian.ValueIterator___str__,None,ValueIterator)
1225ValueIterator.__eq__ = new_instancemethod(_xapian.ValueIterator___eq__,None,ValueIterator)
1226ValueIterator.__ne__ = new_instancemethod(_xapian.ValueIterator___ne__,None,ValueIterator)
1227ValueIterator_swigregister = _xapian.ValueIterator_swigregister
1228ValueIterator_swigregister(ValueIterator)
1229
1230class Document(object):
1231    """
1232    A handle representing a document in a Xapian database.
1233
1234    The Document class fetches information from the database lazily.
1235    Usually this behaviour isn't visible to users (except for the speed
1236    benefits), but if the document in the database is modified or deleted,
1237    then preexisting Document objects may return the old or new versions
1238    of data (or throw Xapian::DocNotFoundError in the case of deletion).
1239
1240    Since Database objects work on a snapshot of the database's state, the
1241    situation above can only happen with a WritableDatabase object, or if
1242    you call Database::reopen() on a Database object.
1243
1244    We recommend you avoid designs where this behaviour is an issue, but
1245    if you need a way to make a non-lazy version of a Document object, you
1246    can do this like so:doc =
1247    Xapian::Document::unserialise(doc.serialise());
1248    """
1249    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
1250    __repr__ = _swig_repr
1251    def __init__(self, *args):
1252        """
1253        Make a new empty Document.
1254
1255        Xapian::Document::Document()
1256        """
1257        _xapian.Document_swiginit(self,_xapian.new_Document(*args))
1258    __swig_destroy__ = _xapian.delete_Document
1259    def get_value(self, *args):
1260        """
1261        Get value by number.
1262
1263        std::string Xapian::Document::get_value(Xapian::valueno slot) const
1264
1265        Returns an empty string if no value with the given number is present
1266        in the document.
1267
1268        Parameters:
1269        -----------
1270
1271        slot:  The number of the value.
1272        """
1273        return _xapian.Document_get_value(self, *args)
1274
1275    def add_value(self, *args):
1276        """
1277        Add a new value.
1278
1279        void Xapian::Document::add_value(Xapian::valueno slot, const
1280        std::string &value)
1281
1282        The new value will replace any existing value with the same number (or
1283        if the new value is empty, it will remove any existing value with the
1284        same number).
1285
1286        Parameters:
1287        -----------
1288
1289        slot:  The value slot to add the value in.
1290
1291        value:  The value to set.
1292        """
1293        return _xapian.Document_add_value(self, *args)
1294
1295    def remove_value(self, *args):
1296        """
1297        Remove any value with the given number.
1298
1299        void Xapian::Document::remove_value(Xapian::valueno slot)
1300        """
1301        return _xapian.Document_remove_value(self, *args)
1302
1303    def clear_values(self):
1304        """
1305        Remove all values associated with the document.
1306
1307        void Xapian::Document::clear_values()
1308        """
1309        return _xapian.Document_clear_values(self)
1310
1311    def get_data(self):
1312        """
1313        Get data stored in the document.
1314
1315        std::string Xapian::Document::get_data() const
1316
1317        This is potentially a relatively expensive operation, and shouldn't
1318        normally be used during the match (e.g. in a PostingSource or match
1319        decider functor. Put data for use by match deciders in a value
1320        instead.
1321        """
1322        return _xapian.Document_get_data(self)
1323
1324    def set_data(self, *args):
1325        """
1326        Set data stored in the document.
1327
1328        void Xapian::Document::set_data(const std::string &data)
1329
1330        Xapian treats the data as an opaque blob. It may try to compress it,
1331        but other than that it will just store it and return it when
1332        requested.
1333
1334        Parameters:
1335        -----------
1336
1337        data:  The data to store.
1338        """
1339        return _xapian.Document_set_data(self, *args)
1340
1341    def add_posting(self, *args):
1342        """
1343        Add an occurrence of a term at a particular position.
1344
1345        void Xapian::Document::add_posting(const std::string &tname,
1346        Xapian::termpos tpos, Xapian::termcount wdfinc=1)
1347
1348        Multiple occurrences of the term at the same position are represented
1349        only once in the positional information, but do increase the wdf.
1350
1351        If the term is not already in the document, it will be added to it.
1352
1353        Parameters:
1354        -----------
1355
1356        tname:  The name of the term.
1357
1358        tpos:  The position of the term.
1359
1360        wdfinc:  The increment that will be applied to the wdf for this term.
1361
1362        """
1363        return _xapian.Document_add_posting(self, *args)
1364
1365    def add_term(self, *args):
1366        """
1367        Add a term to the document, without positional information.
1368
1369        void Xapian::Document::add_term(const std::string &tname,
1370        Xapian::termcount wdfinc=1)
1371
1372        Any existing positional information for the term will be left
1373        unmodified.
1374
1375        Parameters:
1376        -----------
1377
1378        tname:  The name of the term.
1379
1380        wdfinc:  The increment that will be applied to the wdf for this term
1381        (default: 1).
1382        """
1383        return _xapian.Document_add_term(self, *args)
1384
1385    def add_boolean_term(self, *args):
1386        """
1387        Add a boolean filter term to the document.
1388
1389        void Xapian::Document::add_boolean_term(const std::string &term)
1390
1391        This method adds term to the document with wdf of 0 - this is
1392        generally what you want for a term used for boolean filtering as the
1393        wdf of such terms is ignored, and it doesn't make sense for them to
1394        contribute to the document's length.
1395
1396        If the specified term already indexes this document, this method has
1397        no effect.
1398
1399        It is exactly the same as add_term(term, 0).
1400
1401        This method was added in Xapian 1.0.18.
1402
1403        Parameters:
1404        -----------
1405
1406        term:  The term to add.
1407        """
1408        return _xapian.Document_add_boolean_term(self, *args)
1409
1410    def remove_posting(self, *args):
1411        """
1412        Remove a posting of a term from the document.
1413
1414        void Xapian::Document::remove_posting(const std::string &tname,
1415        Xapian::termpos tpos, Xapian::termcount wdfdec=1)
1416
1417        Note that the term will still index the document even if all
1418        occurrences are removed. To remove a term from a document completely,
1419        use remove_term().
1420
1421        Parameters:
1422        -----------
1423
1424        tname:  The name of the term.
1425
1426        tpos:  The position of the term.
1427
1428        wdfdec:  The decrement that will be applied to the wdf when removing
1429        this posting. The wdf will not go below the value of 0.
1430
1431        Parameters:
1432        -----------
1433
1434        Xapian::InvalidArgumentError:  will be thrown if the term is not at
1435        the position specified in the position list for this term in this
1436        document.
1437
1438        Xapian::InvalidArgumentError:  will be thrown if the term is not in
1439        the document
1440        """
1441        return _xapian.Document_remove_posting(self, *args)
1442
1443    def remove_term(self, *args):
1444        """
1445        Remove a term and all postings associated with it.
1446
1447        void Xapian::Document::remove_term(const std::string &tname)
1448
1449        Parameters:
1450        -----------
1451
1452        tname:  The name of the term.
1453
1454        Parameters:
1455        -----------
1456
1457        Xapian::InvalidArgumentError:  will be thrown if the term is not in
1458        the document
1459        """
1460        return _xapian.Document_remove_term(self, *args)
1461
1462    def clear_terms(self):
1463        """
1464        Remove all terms (and postings) from the document.
1465
1466        void Xapian::Document::clear_terms()
1467        """
1468        return _xapian.Document_clear_terms(self)
1469
1470    def termlist_count(self):
1471        """
1472        The length of the termlist - i.e.
1473
1474        Xapian::termcount Xapian::Document::termlist_count() const
1475
1476        the number of different terms which index this document.
1477        """
1478        return _xapian.Document_termlist_count(self)
1479
1480    def termlist_begin(self):
1481        """
1482        Iterator for the terms in this document.
1483
1484        TermIterator Xapian::Document::termlist_begin() const
1485        """
1486        return _xapian.Document_termlist_begin(self)
1487
1488    def termlist_end(self):
1489        """
1490        Equivalent end iterator for termlist_begin().
1491
1492        TermIterator Xapian::Document::termlist_end() const
1493        """
1494        return _xapian.Document_termlist_end(self)
1495
1496    def values_count(self):
1497        """
1498        Count the values in this document.
1499
1500        Xapian::termcount Xapian::Document::values_count() const
1501        """
1502        return _xapian.Document_values_count(self)
1503
1504    def values_begin(self):
1505        """
1506        Iterator for the values in this document.
1507
1508        ValueIterator Xapian::Document::values_begin() const
1509        """
1510        return _xapian.Document_values_begin(self)
1511
1512    def values_end(self):
1513        """
1514        Equivalent end iterator for values_begin().
1515
1516        ValueIteratorEnd_ Xapian::Document::values_end() const
1517        """
1518        return _xapian.Document_values_end(self)
1519
1520    def get_docid(self):
1521        """
1522        Get the document id which is associated with this document (if any).
1523
1524        docid Xapian::Document::get_docid() const
1525
1526        NB If multiple databases are being searched together, then this will
1527        be the document id in the individual database, not the merged
1528        database!
1529
1530        If this document came from a database, return the document id in that
1531        database. Otherwise, return 0 (in Xapian 1.0.22/1.2.4 or later; prior
1532        to this the returned value was uninitialised).
1533        """
1534        return _xapian.Document_get_docid(self)
1535
1536    def serialise(self):
1537        """
1538        Serialise document into a string.
1539
1540        std::string Xapian::Document::serialise() const
1541
1542        The document representation may change between Xapian releases: even
1543        between minor versions. However, it is guaranteed not to change if the
1544        remote database protocol has not changed between releases.
1545        """
1546        return _xapian.Document_serialise(self)
1547
1548    unserialise = staticmethod(_xapian.Document_unserialise)
1549    def __str__(self):
1550        """
1551        Return a string describing this object.
1552
1553        std::string Xapian::Document::get_description() const
1554        """
1555        return _xapian.Document___str__(self)
1556
1557Document.get_value = new_instancemethod(_xapian.Document_get_value,None,Document)
1558Document.add_value = new_instancemethod(_xapian.Document_add_value,None,Document)
1559Document.remove_value = new_instancemethod(_xapian.Document_remove_value,None,Document)
1560Document.clear_values = new_instancemethod(_xapian.Document_clear_values,None,Document)
1561Document.get_data = new_instancemethod(_xapian.Document_get_data,None,Document)
1562Document.set_data = new_instancemethod(_xapian.Document_set_data,None,Document)
1563Document.add_posting = new_instancemethod(_xapian.Document_add_posting,None,Document)
1564Document.add_term = new_instancemethod(_xapian.Document_add_term,None,Document)
1565Document.add_boolean_term = new_instancemethod(_xapian.Document_add_boolean_term,None,Document)
1566Document.remove_posting = new_instancemethod(_xapian.Document_remove_posting,None,Document)
1567Document.remove_term = new_instancemethod(_xapian.Document_remove_term,None,Document)
1568Document.clear_terms = new_instancemethod(_xapian.Document_clear_terms,None,Document)
1569Document.termlist_count = new_instancemethod(_xapian.Document_termlist_count,None,Document)
1570Document.termlist_begin = new_instancemethod(_xapian.Document_termlist_begin,None,Document)
1571Document.termlist_end = new_instancemethod(_xapian.Document_termlist_end,None,Document)
1572Document.values_count = new_instancemethod(_xapian.Document_values_count,None,Document)
1573Document.values_begin = new_instancemethod(_xapian.Document_values_begin,None,Document)
1574Document.values_end = new_instancemethod(_xapian.Document_values_end,None,Document)
1575Document.get_docid = new_instancemethod(_xapian.Document_get_docid,None,Document)
1576Document.serialise = new_instancemethod(_xapian.Document_serialise,None,Document)
1577Document.__str__ = new_instancemethod(_xapian.Document___str__,None,Document)
1578Document_swigregister = _xapian.Document_swigregister
1579Document_swigregister(Document)
1580
1581def Document_unserialise(*args):
1582  return _xapian.Document_unserialise(*args)
1583Document_unserialise = _xapian.Document_unserialise
1584
1585class PostingSource(object):
1586    """
1587    Base class which provides an "external" source of postings.
1588    """
1589    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
1590    __repr__ = _swig_repr
1591    def __init__(self):
1592        if self.__class__ == PostingSource:
1593            _self = None
1594        else:
1595            _self = self
1596        _xapian.PostingSource_swiginit(self,_xapian.new_PostingSource(_self, ))
1597    __swig_destroy__ = _xapian.delete_PostingSource
1598    def get_termfreq_min(self):
1599        """
1600        A lower bound on the number of documents this object can return.
1601
1602        virtual Xapian::doccount Xapian::PostingSource::get_termfreq_min()
1603        const =0
1604
1605        Xapian will always call init() on a PostingSource before calling this
1606        for the first time.
1607        """
1608        return _xapian.PostingSource_get_termfreq_min(self)
1609
1610    def get_termfreq_est(self):
1611        """
1612        An estimate of the number of documents this object can return.
1613
1614        virtual Xapian::doccount Xapian::PostingSource::get_termfreq_est()
1615        const =0
1616
1617        It must always be true that:
1618
1619        get_termfreq_min() <= get_termfreq_est() <= get_termfreq_max()
1620
1621        Xapian will always call init() on a PostingSource before calling this
1622        for the first time.
1623        """
1624        return _xapian.PostingSource_get_termfreq_est(self)
1625
1626    def get_termfreq_max(self):
1627        """
1628        An upper bound on the number of documents this object can return.
1629
1630        virtual Xapian::doccount Xapian::PostingSource::get_termfreq_max()
1631        const =0
1632
1633        Xapian will always call init() on a PostingSource before calling this
1634        for the first time.
1635        """
1636        return _xapian.PostingSource_get_termfreq_max(self)
1637
1638    def get_maxweight(self):
1639        """
1640        Return the currently set upper bound on what get_weight() can return.
1641
1642        Xapian::weight Xapian::PostingSource::get_maxweight() const
1643        """
1644        return _xapian.PostingSource_get_maxweight(self)
1645
1646    def get_weight(self):
1647        """
1648        Return the weight contribution for the current document.
1649
1650        virtual Xapian::weight Xapian::PostingSource::get_weight() const
1651
1652        This default implementation always returns 0, for convenience when
1653        implementing "weight-less" PostingSource subclasses.
1654
1655        This method may assume that it will only be called when there is a
1656        "current document". In detail: Xapian will always call init() on a
1657        PostingSource before calling this for the first time. It will also
1658        only call this if the PostingSource reports that it is pointing to a
1659        valid document (ie, it will not call it before calling at least one of
1660        next(), skip_to() or check(), and will ensure that the PostingSource
1661        is not at the end by calling at_end()).
1662        """
1663        return _xapian.PostingSource_get_weight(self)
1664
1665    def get_docid(self):
1666        """
1667        Return the current docid.
1668
1669        virtual Xapian::docid Xapian::PostingSource::get_docid() const =0
1670
1671        This method may assume that it will only be called when there is a
1672        "current document". See  get_weight() for details.
1673
1674        Note: in the case of a multi-database search, the returned docid
1675        should be in the single subdatabase relevant to this posting source.
1676        See the  init() method for details.
1677        """
1678        return _xapian.PostingSource_get_docid(self)
1679
1680    def next(self, *args):
1681        """
1682        Advance the current position to the next matching document.
1683
1684        virtual void Xapian::PostingSource::next(Xapian::weight min_wt)=0
1685
1686        The PostingSource starts before the first entry in the list, so next()
1687        must be called before any methods which need the context of the
1688        current position.
1689
1690        Xapian will always call init() on a PostingSource before calling this
1691        for the first time.
1692
1693        Parameters:
1694        -----------
1695
1696        min_wt:  The minimum weight contribution that is needed (this is just
1697        a hint which subclasses may ignore).
1698        """
1699        return _xapian.PostingSource_next(self, *args)
1700
1701    def skip_to(self, *args):
1702        """
1703        Advance to the specified docid.
1704
1705        virtual void Xapian::PostingSource::skip_to(Xapian::docid did,
1706        Xapian::weight min_wt)
1707
1708        If the specified docid isn't in the list, position ourselves on the
1709        first document after it (or at_end() if no greater docids are
1710        present).
1711
1712        If the current position is already the specified docid, this method
1713        will leave the position unmodified.
1714
1715        If the specified docid is earlier than the current position, the
1716        behaviour is unspecified. A sensible behaviour would be to leave the
1717        current position unmodified, but it is also reasonable to move to the
1718        specified docid.
1719
1720        The default implementation calls next() repeatedly, which works but
1721        skip_to() can often be implemented much more efficiently.
1722
1723        Xapian will always call init() on a PostingSource before calling this
1724        for the first time.
1725
1726        Note: in the case of a multi-database search, the docid specified is
1727        the docid in the single subdatabase relevant to this posting source.
1728        See the  init() method for details.
1729
1730        Parameters:
1731        -----------
1732
1733        did:  The document id to advance to.
1734
1735        min_wt:  The minimum weight contribution that is needed (this is just
1736        a hint which subclasses may ignore).
1737        """
1738        return _xapian.PostingSource_skip_to(self, *args)
1739
1740    def check(self, *args):
1741        """
1742        Check if the specified docid occurs.
1743
1744        virtual bool Xapian::PostingSource::check(Xapian::docid did,
1745        Xapian::weight min_wt)
1746
1747        The caller is required to ensure that the specified document id did
1748        actually exists in the database. If it does, it must move to that
1749        document id, and return true. If it does not, it may either:
1750
1751        return true, having moved to a definite position (including
1752        "at_end"), which must be the same position as skip_to() would have
1753        moved to.
1754
1755        or
1756
1757        return false, having moved to an "indeterminate" position, such that
1758        a subsequent call to next() or skip_to() will move to the next
1759        matching position after did.
1760
1761        Generally, this method should act like skip_to() and return true if
1762        that can be done at little extra cost.
1763
1764        Otherwise it should simply check if a particular docid is present,
1765        returning true if it is, and false if it isn't.
1766
1767        The default implementation calls skip_to() and always returns true.
1768
1769        Xapian will always call init() on a PostingSource before calling this
1770        for the first time.
1771
1772        Note: in the case of a multi-database search, the docid specified is
1773        the docid in the single subdatabase relevant to this posting source.
1774        See the  init() method for details.
1775
1776        Parameters:
1777        -----------
1778
1779        did:  The document id to check.
1780
1781        min_wt:  The minimum weight contribution that is needed (this is just
1782        a hint which subclasses may ignore).
1783        """
1784        return _xapian.PostingSource_check(self, *args)
1785
1786    def at_end(self):
1787        """
1788        Return true if the current position is past the last entry in this
1789        list.
1790
1791        virtual bool Xapian::PostingSource::at_end() const =0
1792
1793        At least one of  next(),  skip_to() or  check() will be called before
1794        this method is first called.
1795        """
1796        return _xapian.PostingSource_at_end(self)
1797
1798    def name(self):
1799        """
1800        Name of the posting source class.
1801
1802        virtual std::string Xapian::PostingSource::name() const
1803
1804        This is used when serialising and unserialising posting sources; for
1805        example, for performing remote searches.
1806
1807        If the subclass is in a C++ namespace, the namespace should be
1808        included in the name, using "::" as a separator. For example, for a
1809        PostingSource subclass called "FooPostingSource" in the "Xapian"
1810        namespace the result of this call should be
1811        "Xapian::FooPostingSource".
1812
1813        This should only be implemented if serialise() and unserialise() are
1814        also implemented. The default implementation returns an empty string.
1815
1816        If this returns an empty string, Xapian will assume that serialise()
1817        and unserialise() are not implemented.
1818        """
1819        return _xapian.PostingSource_name(self)
1820
1821    def init(self, *args):
1822        """
1823        Set this PostingSource to the start of the list of postings.
1824
1825        virtual void Xapian::PostingSource::init(const Database &db)=0
1826
1827        This is called automatically by the matcher prior to each query being
1828        processed.
1829
1830        If a PostingSource is used for multiple searches,  init() will
1831        therefore be called multiple times, and must handle this by using the
1832        database passed in the most recent call.
1833
1834        Parameters:
1835        -----------
1836
1837        db:  The database which the PostingSource should iterate through.
1838
1839        Note: the database supplied to this method must not be modified: in
1840        particular, the reopen() method should not be called on it.
1841
1842        Note: in the case of a multi-database search, a separate PostingSource
1843        will be used for each database (the separate PostingSources will be
1844        obtained using  clone()), and each PostingSource will be passed one of
1845        the sub-databases as the db parameter here. The db parameter will
1846        therefore always refer to a single database. All docids passed to, or
1847        returned from, the PostingSource refer to docids in that single
1848        database, rather than in the multi- database.
1849        """
1850        return _xapian.PostingSource_init(self, *args)
1851
1852    def __str__(self):
1853        """
1854        Return a string describing this object.
1855
1856        virtual std::string Xapian::PostingSource::get_description() const
1857
1858        This default implementation returns a generic answer. This default it
1859        provided to avoid forcing those deriving their own PostingSource
1860        subclass from having to implement this (they may not care what
1861        get_description() gives for their subclass).
1862        """
1863        return _xapian.PostingSource___str__(self)
1864
1865    def __disown__(self):
1866        self.this.disown()
1867        _xapian.disown_PostingSource(self)
1868        return weakref_proxy(self)
1869PostingSource.get_termfreq_min = new_instancemethod(_xapian.PostingSource_get_termfreq_min,None,PostingSource)
1870PostingSource.get_termfreq_est = new_instancemethod(_xapian.PostingSource_get_termfreq_est,None,PostingSource)
1871PostingSource.get_termfreq_max = new_instancemethod(_xapian.PostingSource_get_termfreq_max,None,PostingSource)
1872PostingSource.get_maxweight = new_instancemethod(_xapian.PostingSource_get_maxweight,None,PostingSource)
1873PostingSource.get_weight = new_instancemethod(_xapian.PostingSource_get_weight,None,PostingSource)
1874PostingSource.get_docid = new_instancemethod(_xapian.PostingSource_get_docid,None,PostingSource)
1875PostingSource.next = new_instancemethod(_xapian.PostingSource_next,None,PostingSource)
1876PostingSource.skip_to = new_instancemethod(_xapian.PostingSource_skip_to,None,PostingSource)
1877PostingSource.check = new_instancemethod(_xapian.PostingSource_check,None,PostingSource)
1878PostingSource.at_end = new_instancemethod(_xapian.PostingSource_at_end,None,PostingSource)
1879PostingSource.name = new_instancemethod(_xapian.PostingSource_name,None,PostingSource)
1880PostingSource.init = new_instancemethod(_xapian.PostingSource_init,None,PostingSource)
1881PostingSource.__str__ = new_instancemethod(_xapian.PostingSource___str__,None,PostingSource)
1882PostingSource_swigregister = _xapian.PostingSource_swigregister
1883PostingSource_swigregister(PostingSource)
1884
1885class ValuePostingSource(PostingSource):
1886    """
1887    A posting source which generates weights from a value slot.
1888
1889    This is a base class for classes which generate weights using values
1890    stored in the specified slot. For example, ValueWeightPostingSource
1891    uses sortable_unserialise to convert values directly to weights.
1892
1893    The upper bound on the weight returned is set to DBL_MAX. Subclasses
1894    should call set_maxweight() in their init() methods after calling
1895    ValuePostingSource::init() if they know a tighter bound on the weight.
1896
1897    """
1898    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
1899    __repr__ = _swig_repr
1900    def __init__(self, *args):
1901        """
1902        Construct a ValuePostingSource.
1903
1904        Xapian::ValuePostingSource::ValuePostingSource(Xapian::valueno slot_)
1905
1906        Parameters:
1907        -----------
1908
1909        slot_:  The value slot to read values from.
1910        """
1911        _xapian.ValuePostingSource_swiginit(self,_xapian.new_ValuePostingSource(*args))
1912    def get_database(self):
1913        """
1914        The database we're reading values from.
1915
1916        Xapian::Database Xapian::ValuePostingSource::get_database() const
1917
1918        Added in 1.2.23 and 1.3.5.
1919        """
1920        return _xapian.ValuePostingSource_get_database(self)
1921
1922    def get_slot(self):
1923        """
1924        The slot we're reading values from.
1925
1926        Xapian::valueno Xapian::ValuePostingSource::get_slot() const
1927
1928        Added in 1.2.23 and 1.3.5.
1929        """
1930        return _xapian.ValuePostingSource_get_slot(self)
1931
1932    def get_value(self):
1933        """
1934        Read current value.
1935
1936        std::string Xapian::ValuePostingSource::get_value() const
1937
1938        Added in 1.2.23 and 1.3.5.
1939        """
1940        return _xapian.ValuePostingSource_get_value(self)
1941
1942    def done(self):
1943        """
1944        End the iteration.
1945
1946        void Xapian::ValuePostingSource::done()
1947
1948        Calls to at_end() will return true after calling this method.
1949
1950        Added in 1.2.23 and 1.3.5.
1951        """
1952        return _xapian.ValuePostingSource_done(self)
1953
1954    def get_started(self):
1955        """
1956        Flag indicating if we've started (true if we have).
1957
1958        bool Xapian::ValuePostingSource::get_started() const
1959
1960        Added in 1.2.23 and 1.3.5.
1961        """
1962        return _xapian.ValuePostingSource_get_started(self)
1963
1964    def set_termfreq_min(self, *args):
1965        """
1966        Set a lower bound on the term frequency.
1967
1968        void Xapian::ValuePostingSource::set_termfreq_min(Xapian::doccount
1969        termfreq_min_)
1970
1971        Subclasses should set this if they are overriding the next(),
1972        skip_to() or check() methods to return fewer documents.
1973
1974        Added in 1.2.23 and 1.3.5.
1975        """
1976        return _xapian.ValuePostingSource_set_termfreq_min(self, *args)
1977
1978    def set_termfreq_est(self, *args):
1979        """
1980        An estimate of the term frequency.
1981
1982        void Xapian::ValuePostingSource::set_termfreq_est(Xapian::doccount
1983        termfreq_est_)
1984
1985        Subclasses should set this if they are overriding the next(),
1986        skip_to() or check() methods.
1987
1988        Added in 1.2.23 and 1.3.5.
1989        """
1990        return _xapian.ValuePostingSource_set_termfreq_est(self, *args)
1991
1992    def set_termfreq_max(self, *args):
1993        """
1994        An upper bound on the term frequency.
1995
1996        void Xapian::ValuePostingSource::set_termfreq_max(Xapian::doccount
1997        termfreq_max_)
1998
1999        Subclasses should set this if they are overriding the next(),
2000        skip_to() or check() methods.
2001
2002        Added in 1.2.23 and 1.3.5.
2003        """
2004        return _xapian.ValuePostingSource_set_termfreq_max(self, *args)
2005
2006    __swig_destroy__ = _xapian.delete_ValuePostingSource
2007ValuePostingSource.get_database = new_instancemethod(_xapian.ValuePostingSource_get_database,None,ValuePostingSource)
2008ValuePostingSource.get_slot = new_instancemethod(_xapian.ValuePostingSource_get_slot,None,ValuePostingSource)
2009ValuePostingSource.get_value = new_instancemethod(_xapian.ValuePostingSource_get_value,None,ValuePostingSource)
2010ValuePostingSource.done = new_instancemethod(_xapian.ValuePostingSource_done,None,ValuePostingSource)
2011ValuePostingSource.get_started = new_instancemethod(_xapian.ValuePostingSource_get_started,None,ValuePostingSource)
2012ValuePostingSource.set_termfreq_min = new_instancemethod(_xapian.ValuePostingSource_set_termfreq_min,None,ValuePostingSource)
2013ValuePostingSource.set_termfreq_est = new_instancemethod(_xapian.ValuePostingSource_set_termfreq_est,None,ValuePostingSource)
2014ValuePostingSource.set_termfreq_max = new_instancemethod(_xapian.ValuePostingSource_set_termfreq_max,None,ValuePostingSource)
2015ValuePostingSource_swigregister = _xapian.ValuePostingSource_swigregister
2016ValuePostingSource_swigregister(ValuePostingSource)
2017
2018class ValueWeightPostingSource(ValuePostingSource):
2019    """
2020    A posting source which reads weights from a value slot.
2021
2022    This returns entries for all documents in the given database which
2023    have a non empty values in the specified slot. It returns a weight
2024    calculated by applying sortable_unserialise to the value stored in the
2025    slot (so the values stored should probably have been calculated by
2026    applying sortable_serialise to a floating point number at index time).
2027
2028    The upper bound on the weight returned is set using the upper bound on
2029    the values in the specified slot, or DBL_MAX if value bounds aren't
2030    supported by the current backend.
2031
2032    For efficiency, this posting source doesn't check that the stored
2033    values are valid in any way, so it will never raise an exception due
2034    to invalid stored values. In particular, it doesn't ensure that the
2035    unserialised values are positive, which is a requirement for weights.
2036    The behaviour if the slot contains values which unserialise to
2037    negative values is undefined.
2038    """
2039    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
2040    __repr__ = _swig_repr
2041    def __init__(self, *args):
2042        """
2043        Construct a ValueWeightPostingSource.
2044
2045        Xapian::ValueWeightPostingSource::ValueWeightPostingSource(Xapian::valueno
2046        slot_)
2047
2048        Parameters:
2049        -----------
2050
2051        slot_:  The value slot to read values from.
2052        """
2053        _xapian.ValueWeightPostingSource_swiginit(self,_xapian.new_ValueWeightPostingSource(*args))
2054    __swig_destroy__ = _xapian.delete_ValueWeightPostingSource
2055ValueWeightPostingSource_swigregister = _xapian.ValueWeightPostingSource_swigregister
2056ValueWeightPostingSource_swigregister(ValueWeightPostingSource)
2057
2058class DecreasingValueWeightPostingSource(ValueWeightPostingSource):
2059    """
2060    Read weights from a value which is known to decrease as docid
2061    increases.
2062
2063    This posting source can be used, like ValueWeightPostingSource, to add
2064    a weight contribution to a query based on the values stored in a slot.
2065    The values in the slot must be serialised as by  sortable_serialise().
2066
2067    However, this posting source is additionally given a range of document
2068    IDs, within which the weight is known to be decreasing. ie, for all
2069    documents with ids A and B within this range (including the
2070    endpoints), where A is less than B, the weight of A is less than or
2071    equal to the weight of B. This can allow the posting source to skip to
2072    the end of the range quickly if insufficient weight is left in the
2073    posting source for a particular source.
2074
2075    By default, the range is assumed to cover all document IDs.
2076
2077    The ordering property can be arranged at index time, or by sorting an
2078    indexed database to produce a new, sorted, database.
2079    """
2080    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
2081    __repr__ = _swig_repr
2082    def __init__(self, *args):
2083        """
2084        Xapian::DecreasingValueWeightPostingSource::DecreasingValueWeightPostingSource(Xapian::valueno
2085        slot_, Xapian::docid range_start_=0, Xapian::docid range_end_=0)
2086        """
2087        _xapian.DecreasingValueWeightPostingSource_swiginit(self,_xapian.new_DecreasingValueWeightPostingSource(*args))
2088    __swig_destroy__ = _xapian.delete_DecreasingValueWeightPostingSource
2089DecreasingValueWeightPostingSource_swigregister = _xapian.DecreasingValueWeightPostingSource_swigregister
2090DecreasingValueWeightPostingSource_swigregister(DecreasingValueWeightPostingSource)
2091
2092class ValueMapPostingSource(ValuePostingSource):
2093    """
2094    A posting source which looks up weights in a map using values as the
2095    key.
2096
2097    This allows will return entries for all documents in the given
2098    database which have a value in the slot specified. The values will be
2099    mapped to the corresponding weight in the weight map. If there is no
2100    mapping for a particular value, the default weight will be returned
2101    (which itself defaults to 0.0).
2102    """
2103    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
2104    __repr__ = _swig_repr
2105    def __init__(self, *args):
2106        """
2107        Construct a ValueWeightPostingSource.
2108
2109        Xapian::ValueMapPostingSource::ValueMapPostingSource(Xapian::valueno
2110        slot_)
2111
2112        Parameters:
2113        -----------
2114
2115        slot_:  The value slot to read values from.
2116        """
2117        _xapian.ValueMapPostingSource_swiginit(self,_xapian.new_ValueMapPostingSource(*args))
2118    def add_mapping(self, *args):
2119        """
2120        Add a mapping.
2121
2122        void Xapian::ValueMapPostingSource::add_mapping(const std::string
2123        &key, double wt)
2124
2125        Parameters:
2126        -----------
2127
2128        key:  The key looked up from the value slot.
2129
2130        wt:  The weight to give this key.
2131        """
2132        return _xapian.ValueMapPostingSource_add_mapping(self, *args)
2133
2134    def clear_mappings(self):
2135        """
2136        Clear all mappings.
2137
2138        void Xapian::ValueMapPostingSource::clear_mappings()
2139        """
2140        return _xapian.ValueMapPostingSource_clear_mappings(self)
2141
2142    def set_default_weight(self, *args):
2143        """
2144        Set a default weight for document values not in the map.
2145
2146        void Xapian::ValueMapPostingSource::set_default_weight(double wt)
2147
2148        Parameters:
2149        -----------
2150
2151        wt:  The weight to set as the default.
2152        """
2153        return _xapian.ValueMapPostingSource_set_default_weight(self, *args)
2154
2155    __swig_destroy__ = _xapian.delete_ValueMapPostingSource
2156ValueMapPostingSource.add_mapping = new_instancemethod(_xapian.ValueMapPostingSource_add_mapping,None,ValueMapPostingSource)
2157ValueMapPostingSource.clear_mappings = new_instancemethod(_xapian.ValueMapPostingSource_clear_mappings,None,ValueMapPostingSource)
2158ValueMapPostingSource.set_default_weight = new_instancemethod(_xapian.ValueMapPostingSource_set_default_weight,None,ValueMapPostingSource)
2159ValueMapPostingSource_swigregister = _xapian.ValueMapPostingSource_swigregister
2160ValueMapPostingSource_swigregister(ValueMapPostingSource)
2161
2162class FixedWeightPostingSource(PostingSource):
2163    """
2164    A posting source which returns a fixed weight for all documents.
2165
2166    This returns entries for all documents in the given database, with a
2167    fixed weight (specified by a parameter to the constructor).
2168    """
2169    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
2170    __repr__ = _swig_repr
2171    def __init__(self, *args):
2172        """
2173        Construct a FixedWeightPostingSource.
2174
2175        Xapian::FixedWeightPostingSource::FixedWeightPostingSource(Xapian::weight
2176        wt)
2177
2178        Parameters:
2179        -----------
2180
2181        wt:  The fixed weight to return.
2182        """
2183        _xapian.FixedWeightPostingSource_swiginit(self,_xapian.new_FixedWeightPostingSource(*args))
2184    __swig_destroy__ = _xapian.delete_FixedWeightPostingSource
2185FixedWeightPostingSource_swigregister = _xapian.FixedWeightPostingSource_swigregister
2186FixedWeightPostingSource_swigregister(FixedWeightPostingSource)
2187
2188class MSet(object):
2189    """
2190    A match set ( MSet).
2191
2192    This class represents (a portion of) the results of a query.
2193    """
2194    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
2195    __repr__ = _swig_repr
2196    def __init__(self, *args):
2197        """
2198        Copying is allowed (and is cheap).
2199
2200        Xapian::MSet::MSet(const MSet &other)
2201        """
2202        _xapian.MSet_swiginit(self,_xapian.new_MSet(*args))
2203    __swig_destroy__ = _xapian.delete_MSet
2204    def fetch(self, *args):
2205        """
2206        Fetch all the items in the MSet.
2207
2208        void Xapian::MSet::fetch() const
2209        """
2210        return _xapian.MSet_fetch(self, *args)
2211
2212    def convert_to_percent(self, *args):
2213        """
2214        Return the percentage score for a particular item.
2215
2216        Xapian::percent Xapian::MSet::convert_to_percent(const MSetIterator
2217        &it) const
2218        """
2219        return _xapian.MSet_convert_to_percent(self, *args)
2220
2221    def get_termfreq(self, *args):
2222        """
2223        Return the term frequency of the given query term.
2224
2225        Xapian::doccount Xapian::MSet::get_termfreq(const std::string &tname)
2226        const
2227
2228        Parameters:
2229        -----------
2230
2231        tname:  The term to look for.
2232
2233        This is sometimes more efficient than asking the database directly for
2234        the term frequency - in particular, if the term was in the query, its
2235        frequency will usually be cached in the MSet.
2236        """
2237        return _xapian.MSet_get_termfreq(self, *args)
2238
2239    def get_termweight(self, *args):
2240        """
2241        Return the term weight of the given query term.
2242
2243        Xapian::weight Xapian::MSet::get_termweight(const std::string &tname)
2244        const
2245
2246        Parameters:
2247        -----------
2248
2249        tname:  The term to look for.
2250
2251        Parameters:
2252        -----------
2253
2254        Xapian::InvalidArgumentError:  is thrown if the term was not in the
2255        query.
2256        """
2257        return _xapian.MSet_get_termweight(self, *args)
2258
2259    def get_firstitem(self):
2260        """
2261        The index of the first item in the result which was put into the MSet.
2262
2263        Xapian::doccount Xapian::MSet::get_firstitem() const
2264
2265        This corresponds to the parameter "first" specified in
2266        Xapian::Enquire::get_mset(). A value of 0 corresponds to the highest
2267        result being the first item in the MSet.
2268        """
2269        return _xapian.MSet_get_firstitem(self)
2270
2271    def get_matches_lower_bound(self):
2272        """
2273        A lower bound on the number of documents in the database which match
2274        the query.
2275
2276        Xapian::doccount Xapian::MSet::get_matches_lower_bound() const
2277
2278        This figure takes into account collapsing of duplicates, and weighting
2279        cutoff values.
2280
2281        This number is usually considerably less than the actual number of
2282        documents which match the query.
2283        """
2284        return _xapian.MSet_get_matches_lower_bound(self)
2285
2286    def get_matches_estimated(self):
2287        """
2288        An estimate for the number of documents in the database which match
2289        the query.
2290
2291        Xapian::doccount Xapian::MSet::get_matches_estimated() const
2292
2293        This figure takes into account collapsing of duplicates, and weighting
2294        cutoff values.
2295
2296        This value is returned because there is sometimes a request to display
2297        such information. However, our experience is that presenting this
2298        value to users causes them to worry about the large number of results,
2299        rather than how useful those at the top of the result set are, and is
2300        thus undesirable.
2301        """
2302        return _xapian.MSet_get_matches_estimated(self)
2303
2304    def get_matches_upper_bound(self):
2305        """
2306        An upper bound on the number of documents in the database which match
2307        the query.
2308
2309        Xapian::doccount Xapian::MSet::get_matches_upper_bound() const
2310
2311        This figure takes into account collapsing of duplicates, and weighting
2312        cutoff values.
2313
2314        This number is usually considerably greater than the actual number of
2315        documents which match the query.
2316        """
2317        return _xapian.MSet_get_matches_upper_bound(self)
2318
2319    def get_uncollapsed_matches_lower_bound(self):
2320        """
2321        A lower bound on the number of documents in the database which would
2322        match the query if collapsing wasn't used.
2323
2324        Xapian::doccount Xapian::MSet::get_uncollapsed_matches_lower_bound()
2325        const
2326        """
2327        return _xapian.MSet_get_uncollapsed_matches_lower_bound(self)
2328
2329    def get_uncollapsed_matches_estimated(self):
2330        """
2331        A estimate of the number of documents in the database which would
2332        match the query if collapsing wasn't used.
2333
2334        Xapian::doccount Xapian::MSet::get_uncollapsed_matches_estimated()
2335        const
2336        """
2337        return _xapian.MSet_get_uncollapsed_matches_estimated(self)
2338
2339    def get_uncollapsed_matches_upper_bound(self):
2340        """
2341        A upper bound on the number of documents in the database which would
2342        match the query if collapsing wasn't used.
2343
2344        Xapian::doccount Xapian::MSet::get_uncollapsed_matches_upper_bound()
2345        const
2346        """
2347        return _xapian.MSet_get_uncollapsed_matches_upper_bound(self)
2348
2349    def get_max_possible(self):
2350        """
2351        The maximum possible weight in the MSet.
2352
2353        Xapian::weight Xapian::MSet::get_max_possible() const
2354
2355        This weight is likely not to be attained in the set of results, but
2356        represents an upper bound on the weight which a document could attain
2357        for the given query.
2358        """
2359        return _xapian.MSet_get_max_possible(self)
2360
2361    def get_max_attained(self):
2362        """
2363        The greatest weight which is attained by any document in the database.
2364
2365        Xapian::weight Xapian::MSet::get_max_attained() const
2366
2367        If firstitem == 0 and the primary ordering is by relevance, this is
2368        the weight of the first entry in the MSet.
2369
2370        If no documents are found by the query, this will be 0.
2371
2372        Note that calculation of max_attained requires calculation of at least
2373        one result item - therefore, if no items were requested when the query
2374        was performed (by specifying maxitems = 0 in
2375        Xapian::Enquire::get_mset()), this value will be 0.
2376        """
2377        return _xapian.MSet_get_max_attained(self)
2378
2379    def size(self):
2380        """
2381        The number of items in this MSet.
2382
2383        Xapian::doccount Xapian::MSet::size() const
2384        """
2385        return _xapian.MSet_size(self)
2386
2387    def empty(self):
2388        """
2389        Test if this MSet is empty.
2390
2391        bool Xapian::MSet::empty() const
2392        """
2393        return _xapian.MSet_empty(self)
2394
2395    def begin(self):
2396        """
2397        Iterator for the items in this MSet.
2398
2399        MSetIterator Xapian::MSet::begin() const
2400        """
2401        return _xapian.MSet_begin(self)
2402
2403    def end(self):
2404        """
2405        End iterator corresponding to begin()
2406
2407        MSetIterator Xapian::MSet::end() const
2408        """
2409        return _xapian.MSet_end(self)
2410
2411    def back(self):
2412        """
2413        Iterator pointing to the last element of this MSet.
2414
2415        MSetIterator Xapian::MSet::back() const
2416        """
2417        return _xapian.MSet_back(self)
2418
2419    def _get_hit_internal(self, *args):
2420        """
2421        Get an item from the MSet.
2422
2423        The supplied index is relative to the start of the MSet, not the absolute rank
2424        of the item.
2425        """
2426        return _xapian.MSet__get_hit_internal(self, *args)
2427
2428    def __str__(self):
2429        """
2430        Return a string describing this object.
2431
2432        std::string Xapian::MSet::get_description() const
2433        """
2434        return _xapian.MSet___str__(self)
2435
2436    items = _swig_property(_xapian.MSet_items_get)
2437MSet.fetch = new_instancemethod(_xapian.MSet_fetch,None,MSet)
2438MSet.convert_to_percent = new_instancemethod(_xapian.MSet_convert_to_percent,None,MSet)
2439MSet.get_termfreq = new_instancemethod(_xapian.MSet_get_termfreq,None,MSet)
2440MSet.get_termweight = new_instancemethod(_xapian.MSet_get_termweight,None,MSet)
2441MSet.get_firstitem = new_instancemethod(_xapian.MSet_get_firstitem,None,MSet)
2442MSet.get_matches_lower_bound = new_instancemethod(_xapian.MSet_get_matches_lower_bound,None,MSet)
2443MSet.get_matches_estimated = new_instancemethod(_xapian.MSet_get_matches_estimated,None,MSet)
2444MSet.get_matches_upper_bound = new_instancemethod(_xapian.MSet_get_matches_upper_bound,None,MSet)
2445MSet.get_uncollapsed_matches_lower_bound = new_instancemethod(_xapian.MSet_get_uncollapsed_matches_lower_bound,None,MSet)
2446MSet.get_uncollapsed_matches_estimated = new_instancemethod(_xapian.MSet_get_uncollapsed_matches_estimated,None,MSet)
2447MSet.get_uncollapsed_matches_upper_bound = new_instancemethod(_xapian.MSet_get_uncollapsed_matches_upper_bound,None,MSet)
2448MSet.get_max_possible = new_instancemethod(_xapian.MSet_get_max_possible,None,MSet)
2449MSet.get_max_attained = new_instancemethod(_xapian.MSet_get_max_attained,None,MSet)
2450MSet.size = new_instancemethod(_xapian.MSet_size,None,MSet)
2451MSet.empty = new_instancemethod(_xapian.MSet_empty,None,MSet)
2452MSet.begin = new_instancemethod(_xapian.MSet_begin,None,MSet)
2453MSet.end = new_instancemethod(_xapian.MSet_end,None,MSet)
2454MSet.back = new_instancemethod(_xapian.MSet_back,None,MSet)
2455MSet._get_hit_internal = new_instancemethod(_xapian.MSet__get_hit_internal,None,MSet)
2456MSet.get_document_percentage = new_instancemethod(_xapian.MSet_get_document_percentage,None,MSet)
2457MSet.get_document = new_instancemethod(_xapian.MSet_get_document,None,MSet)
2458MSet.get_docid = new_instancemethod(_xapian.MSet_get_docid,None,MSet)
2459MSet.__str__ = new_instancemethod(_xapian.MSet___str__,None,MSet)
2460MSet.__cmp__ = new_instancemethod(_xapian.MSet___cmp__,None,MSet)
2461MSet_swigregister = _xapian.MSet_swigregister
2462MSet_swigregister(MSet)
2463
2464class MSetIterator(object):
2465    """
2466    An iterator pointing to items in an MSet.
2467
2468    This is used for access to individual results of a match.
2469    """
2470    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
2471    __repr__ = _swig_repr
2472    def __init__(self, *args):
2473        """
2474        Copying is allowed (and is cheap).
2475
2476        Xapian::MSetIterator::MSetIterator(const MSetIterator &other)
2477        """
2478        _xapian.MSetIterator_swiginit(self,_xapian.new_MSetIterator(*args))
2479    __swig_destroy__ = _xapian.delete_MSetIterator
2480    def get_document(self):
2481        """
2482        Get a Xapian::Document object for the current position.
2483
2484        Xapian::Document Xapian::MSetIterator::get_document() const
2485
2486        This method returns a Xapian::Document object which provides the
2487        information about the document pointed to by the MSetIterator.
2488
2489        If the underlying database has suitable support, using this call
2490        (rather than asking the database for a document based on its document
2491        ID) will enable the system to ensure that the correct data is
2492        returned, and that the document has not been deleted or changed since
2493        the query was performed.
2494
2495        A Xapian::Document object containing the document data.
2496
2497        Parameters:
2498        -----------
2499
2500        Xapian::DocNotFoundError:  The document specified could not be found
2501        in the database.
2502        """
2503        return _xapian.MSetIterator_get_document(self)
2504
2505    def get_rank(self):
2506        """
2507        Get the rank of the document at the current position.
2508
2509        Xapian::doccount Xapian::MSetIterator::get_rank() const
2510
2511        The rank is the position that this document is at in the ordered list
2512        of results of the query. The result is 0-based - i.e. the top-ranked
2513        document has a rank of 0.
2514        """
2515        return _xapian.MSetIterator_get_rank(self)
2516
2517    def get_weight(self):
2518        """
2519        Get the weight of the document at the current position.
2520
2521        Xapian::weight Xapian::MSetIterator::get_weight() const
2522        """
2523        return _xapian.MSetIterator_get_weight(self)
2524
2525    def get_collapse_key(self):
2526        """
2527        Get the collapse key for this document.
2528
2529        std::string Xapian::MSetIterator::get_collapse_key() const
2530        """
2531        return _xapian.MSetIterator_get_collapse_key(self)
2532
2533    def get_collapse_count(self):
2534        """
2535        Get an estimate of the number of documents that have been collapsed
2536        into this one.
2537
2538        Xapian::doccount Xapian::MSetIterator::get_collapse_count() const
2539
2540        The estimate will always be less than or equal to the actual number of
2541        other documents satisfying the match criteria with the same collapse
2542        key as this document.
2543
2544        This method may return 0 even though there are other documents with
2545        the same collapse key which satisfying the match criteria. However if
2546        this method returns non-zero, there definitely are other such
2547        documents. So this method may be used to inform the user that there
2548        are "at least N other matches in this group", or to control whether
2549        to offer a "show other documents in this group" feature (but note
2550        that it may not offer it in every case where it would show other
2551        documents).
2552        """
2553        return _xapian.MSetIterator_get_collapse_count(self)
2554
2555    def get_percent(self):
2556        """
2557        This returns the weight of the document as a percentage score.
2558
2559        Xapian::percent Xapian::MSetIterator::get_percent() const
2560
2561        The return value will be an integer in the range 0 to 100: 0 meaning
2562        that the item did not match the query at all.
2563
2564        The intention is that the highest weighted document will get 100 if it
2565        matches all the weight-contributing terms in the query. However,
2566        currently it may get a lower percentage score if you use a
2567        MatchDecider and the sorting is primarily by value. In this case, the
2568        percentage for a particular document may vary depending on the first,
2569        max_size, and checkatleast parameters passed to Enquire::get_mset()
2570        (this bug is hard to fix without having to apply the MatchDecider to
2571        potentially many more documents, which is potentially costly).
2572        """
2573        return _xapian.MSetIterator_get_percent(self)
2574
2575    def __str__(self):
2576        """
2577        Return a string describing this object.
2578
2579        std::string Xapian::MSetIterator::get_description() const
2580        """
2581        return _xapian.MSetIterator___str__(self)
2582
2583MSetIterator.get_docid = new_instancemethod(_xapian.MSetIterator_get_docid,None,MSetIterator)
2584MSetIterator.next = new_instancemethod(_xapian.MSetIterator_next,None,MSetIterator)
2585MSetIterator.prev = new_instancemethod(_xapian.MSetIterator_prev,None,MSetIterator)
2586MSetIterator.equals = new_instancemethod(_xapian.MSetIterator_equals,None,MSetIterator)
2587MSetIterator.get_document = new_instancemethod(_xapian.MSetIterator_get_document,None,MSetIterator)
2588MSetIterator.get_rank = new_instancemethod(_xapian.MSetIterator_get_rank,None,MSetIterator)
2589MSetIterator.get_weight = new_instancemethod(_xapian.MSetIterator_get_weight,None,MSetIterator)
2590MSetIterator.get_collapse_key = new_instancemethod(_xapian.MSetIterator_get_collapse_key,None,MSetIterator)
2591MSetIterator.get_collapse_count = new_instancemethod(_xapian.MSetIterator_get_collapse_count,None,MSetIterator)
2592MSetIterator.get_percent = new_instancemethod(_xapian.MSetIterator_get_percent,None,MSetIterator)
2593MSetIterator.__str__ = new_instancemethod(_xapian.MSetIterator___str__,None,MSetIterator)
2594MSetIterator.__eq__ = new_instancemethod(_xapian.MSetIterator___eq__,None,MSetIterator)
2595MSetIterator.__ne__ = new_instancemethod(_xapian.MSetIterator___ne__,None,MSetIterator)
2596MSetIterator_swigregister = _xapian.MSetIterator_swigregister
2597MSetIterator_swigregister(MSetIterator)
2598
2599class ESet(object):
2600    """
2601    Class representing an ordered set of expand terms (an ESet).
2602
2603    This set represents the results of an expand operation, which is
2604    performed by Xapian::Enquire::get_eset().
2605    """
2606    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
2607    __repr__ = _swig_repr
2608    def __init__(self, *args):
2609        """
2610        Copying is allowed (and is cheap).
2611
2612        Xapian::ESet::ESet(const ESet &other)
2613        """
2614        _xapian.ESet_swiginit(self,_xapian.new_ESet(*args))
2615    __swig_destroy__ = _xapian.delete_ESet
2616    def get_ebound(self):
2617        """
2618        A lower bound on the number of terms which are in the full set of
2619        results of the expand.
2620
2621        Xapian::termcount Xapian::ESet::get_ebound() const
2622
2623        This will be greater than or equal to size()
2624        """
2625        return _xapian.ESet_get_ebound(self)
2626
2627    def size(self):
2628        """
2629        The number of terms in this E-Set.
2630
2631        Xapian::termcount Xapian::ESet::size() const
2632        """
2633        return _xapian.ESet_size(self)
2634
2635    def empty(self):
2636        """
2637        Test if this E-Set is empty.
2638
2639        bool Xapian::ESet::empty() const
2640        """
2641        return _xapian.ESet_empty(self)
2642
2643    def begin(self):
2644        """
2645        Iterator for the terms in this E-Set.
2646
2647        ESetIterator Xapian::ESet::begin() const
2648        """
2649        return _xapian.ESet_begin(self)
2650
2651    def end(self):
2652        """
2653        End iterator corresponding to begin()
2654
2655        ESetIterator Xapian::ESet::end() const
2656        """
2657        return _xapian.ESet_end(self)
2658
2659    def back(self):
2660        """
2661        Iterator pointing to the last element of this E-Set.
2662
2663        ESetIterator Xapian::ESet::back() const
2664        """
2665        return _xapian.ESet_back(self)
2666
2667    def __str__(self):
2668        """
2669        Return a string describing this object.
2670
2671        std::string Xapian::ESet::get_description() const
2672        """
2673        return _xapian.ESet___str__(self)
2674
2675    items = _swig_property(_xapian.ESet_items_get)
2676ESet.get_ebound = new_instancemethod(_xapian.ESet_get_ebound,None,ESet)
2677ESet.size = new_instancemethod(_xapian.ESet_size,None,ESet)
2678ESet.empty = new_instancemethod(_xapian.ESet_empty,None,ESet)
2679ESet.begin = new_instancemethod(_xapian.ESet_begin,None,ESet)
2680ESet.end = new_instancemethod(_xapian.ESet_end,None,ESet)
2681ESet.back = new_instancemethod(_xapian.ESet_back,None,ESet)
2682ESet.__str__ = new_instancemethod(_xapian.ESet___str__,None,ESet)
2683ESet_swigregister = _xapian.ESet_swigregister
2684ESet_swigregister(ESet)
2685
2686class ESetIterator(object):
2687    """
2688    Iterate through terms in the ESet.
2689    """
2690    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
2691    __repr__ = _swig_repr
2692    def __init__(self, *args):
2693        """
2694        Copying is allowed (and is cheap).
2695
2696        Xapian::ESetIterator::ESetIterator(const ESetIterator &other)
2697        """
2698        _xapian.ESetIterator_swiginit(self,_xapian.new_ESetIterator(*args))
2699    __swig_destroy__ = _xapian.delete_ESetIterator
2700    def get_weight(self):
2701        """
2702        Get the weight of the term at the current position.
2703
2704        Xapian::weight Xapian::ESetIterator::get_weight() const
2705        """
2706        return _xapian.ESetIterator_get_weight(self)
2707
2708    def __str__(self):
2709        """
2710        Return a string describing this object.
2711
2712        std::string Xapian::ESetIterator::get_description() const
2713        """
2714        return _xapian.ESetIterator___str__(self)
2715
2716ESetIterator.get_term = new_instancemethod(_xapian.ESetIterator_get_term,None,ESetIterator)
2717ESetIterator.next = new_instancemethod(_xapian.ESetIterator_next,None,ESetIterator)
2718ESetIterator.prev = new_instancemethod(_xapian.ESetIterator_prev,None,ESetIterator)
2719ESetIterator.equals = new_instancemethod(_xapian.ESetIterator_equals,None,ESetIterator)
2720ESetIterator.get_weight = new_instancemethod(_xapian.ESetIterator_get_weight,None,ESetIterator)
2721ESetIterator.__str__ = new_instancemethod(_xapian.ESetIterator___str__,None,ESetIterator)
2722ESetIterator.__eq__ = new_instancemethod(_xapian.ESetIterator___eq__,None,ESetIterator)
2723ESetIterator.__ne__ = new_instancemethod(_xapian.ESetIterator___ne__,None,ESetIterator)
2724ESetIterator_swigregister = _xapian.ESetIterator_swigregister
2725ESetIterator_swigregister(ESetIterator)
2726
2727class RSet(object):
2728    """
2729    A relevance set (R-Set).
2730
2731    This is the set of documents which are marked as relevant, for use in
2732    modifying the term weights, and in performing query expansion.
2733    """
2734    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
2735    __repr__ = _swig_repr
2736    def __init__(self, *args):
2737        """
2738        Default constructor.
2739
2740        Xapian::RSet::RSet()
2741        """
2742        _xapian.RSet_swiginit(self,_xapian.new_RSet(*args))
2743    __swig_destroy__ = _xapian.delete_RSet
2744    def size(self):
2745        """
2746        The number of documents in this R-Set.
2747
2748        Xapian::doccount Xapian::RSet::size() const
2749        """
2750        return _xapian.RSet_size(self)
2751
2752    def empty(self):
2753        """
2754        Test if this R-Set is empty.
2755
2756        bool Xapian::RSet::empty() const
2757        """
2758        return _xapian.RSet_empty(self)
2759
2760    def add_document(self, *args):
2761        """
2762        Add a document to the relevance set.
2763
2764        void Xapian::RSet::add_document(const Xapian::MSetIterator &i)
2765        """
2766        return _xapian.RSet_add_document(self, *args)
2767
2768    def remove_document(self, *args):
2769        """
2770        Remove a document from the relevance set.
2771
2772        void Xapian::RSet::remove_document(const Xapian::MSetIterator &i)
2773        """
2774        return _xapian.RSet_remove_document(self, *args)
2775
2776    def contains(self, *args):
2777        """
2778        Test if a given document in the relevance set.
2779
2780        bool Xapian::RSet::contains(const Xapian::MSetIterator &i) const
2781        """
2782        return _xapian.RSet_contains(self, *args)
2783
2784    def __str__(self):
2785        """
2786        Return a string describing this object.
2787
2788        std::string Xapian::RSet::get_description() const
2789        """
2790        return _xapian.RSet___str__(self)
2791
2792RSet.size = new_instancemethod(_xapian.RSet_size,None,RSet)
2793RSet.empty = new_instancemethod(_xapian.RSet_empty,None,RSet)
2794RSet.add_document = new_instancemethod(_xapian.RSet_add_document,None,RSet)
2795RSet.remove_document = new_instancemethod(_xapian.RSet_remove_document,None,RSet)
2796RSet.contains = new_instancemethod(_xapian.RSet_contains,None,RSet)
2797RSet.__str__ = new_instancemethod(_xapian.RSet___str__,None,RSet)
2798RSet_swigregister = _xapian.RSet_swigregister
2799RSet_swigregister(RSet)
2800
2801class MatchDecider(object):
2802    """
2803    Base class for matcher decision functor.
2804    """
2805    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
2806    __repr__ = _swig_repr
2807    __swig_destroy__ = _xapian.delete_MatchDecider
2808    def __init__(self):
2809        if self.__class__ == MatchDecider:
2810            _self = None
2811        else:
2812            _self = self
2813        _xapian.MatchDecider_swiginit(self,_xapian.new_MatchDecider(_self, ))
2814    def __disown__(self):
2815        self.this.disown()
2816        _xapian.disown_MatchDecider(self)
2817        return weakref_proxy(self)
2818MatchDecider.__call__ = new_instancemethod(_xapian.MatchDecider___call__,None,MatchDecider)
2819MatchDecider_swigregister = _xapian.MatchDecider_swigregister
2820MatchDecider_swigregister(MatchDecider)
2821
2822class ExpandDecider(object):
2823    """
2824    Virtual base class for expand decider functor.
2825    """
2826    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
2827    __repr__ = _swig_repr
2828    __swig_destroy__ = _xapian.delete_ExpandDecider
2829    def __init__(self):
2830        if self.__class__ == ExpandDecider:
2831            _self = None
2832        else:
2833            _self = self
2834        _xapian.ExpandDecider_swiginit(self,_xapian.new_ExpandDecider(_self, ))
2835    def __disown__(self):
2836        self.this.disown()
2837        _xapian.disown_ExpandDecider(self)
2838        return weakref_proxy(self)
2839ExpandDecider.__call__ = new_instancemethod(_xapian.ExpandDecider___call__,None,ExpandDecider)
2840ExpandDecider_swigregister = _xapian.ExpandDecider_swigregister
2841ExpandDecider_swigregister(ExpandDecider)
2842
2843class Enquire(object):
2844    """
2845    This class provides an interface to the information retrieval system
2846    for the purpose of searching.
2847
2848    Databases are usually opened lazily, so exceptions may not be thrown
2849    where you would expect them to be. You should catch Xapian::Error
2850    exceptions when calling any method in Xapian::Enquire.
2851
2852    Parameters:
2853    -----------
2854
2855    Xapian::InvalidArgumentError:  will be thrown if an invalid argument
2856    is supplied, for example, an unknown database type.
2857    """
2858    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
2859    __repr__ = _swig_repr
2860    def __init__(self, *args):
2861        """
2862        Create a Xapian::Enquire object.
2863
2864        Xapian::Enquire::Enquire(const Database &database, ErrorHandler
2865        *errorhandler_=0)
2866
2867        This specification cannot be changed once the Xapian::Enquire is
2868        opened: you must create a new Xapian::Enquire object to access a
2869        different database, or set of databases.
2870
2871        The database supplied must have been initialised (ie, must not be the
2872        result of calling the Database::Database() constructor). If you need
2873        to handle a situation where you have no index gracefully, a database
2874        created with InMemory::open() can be passed here, which represents a
2875        completely empty database.
2876
2877        Parameters:
2878        -----------
2879
2880        database:  Specification of the database or databases to use.
2881
2882        errorhandler_:  A pointer to the error handler to use. Ownership of
2883        the object pointed to is not assumed by the Xapian::Enquire object -
2884        the user should delete the Xapian::ErrorHandler object after the
2885        Xapian::Enquire object is deleted. To use no error handler, this
2886        parameter should be 0.
2887
2888        Parameters:
2889        -----------
2890
2891        Xapian::InvalidArgumentError:  will be thrown if an empty Database
2892        object is supplied.
2893        """
2894        _xapian.Enquire_swiginit(self,_xapian.new_Enquire(*args))
2895    __swig_destroy__ = _xapian.delete_Enquire
2896    def set_query(self, *args):
2897        """
2898        Set the query to run.
2899
2900        void Xapian::Enquire::set_query(const Xapian::Query &query,
2901        Xapian::termcount qlen=0)
2902
2903        Parameters:
2904        -----------
2905
2906        query:  the new query to run.
2907
2908        qlen:  the query length to use in weight calculations - by default the
2909        sum of the wqf of all terms is used.
2910        """
2911        return _xapian.Enquire_set_query(self, *args)
2912
2913    def get_query(self):
2914        """
2915        Get the current query.
2916
2917        const Xapian::Query& Xapian::Enquire::get_query() const
2918
2919        If called before set_query(), this will return a default initialised
2920        Query object.
2921        """
2922        return _xapian.Enquire_get_query(self)
2923
2924    def add_matchspy(self, *args):
2925        """
2926        Add a matchspy.
2927
2928        void Xapian::Enquire::add_matchspy(MatchSpy *spy)
2929
2930        This matchspy will be called with some of the documents which match
2931        the query, during the match process. Exactly which of the matching
2932        documents are passed to it depends on exactly when certain
2933        optimisations occur during the match process, but it can be controlled
2934        to some extent by setting the checkatleast parameter to  get_mset().
2935
2936        In particular, if there are enough matching documents, at least the
2937        number specified by checkatleast will be passed to the matchspy. This
2938        means that you can force the matchspy to be shown all matching
2939        documents by setting checkatleast to the number of documents in the
2940        database.
2941
2942        Parameters:
2943        -----------
2944
2945        spy:  The MatchSpy subclass to add. The caller must ensure that this
2946        remains valid while the Enquire object remains active, or until
2947        clear_matchspies() is called.
2948        """
2949        return _xapian.Enquire_add_matchspy(self, *args)
2950
2951    def clear_matchspies(self):
2952        """
2953        Remove all the matchspies.
2954
2955        void Xapian::Enquire::clear_matchspies()
2956        """
2957        return _xapian.Enquire_clear_matchspies(self)
2958
2959    def set_weighting_scheme(self, *args):
2960        """
2961        Set the weighting scheme to use for queries.
2962
2963        void Xapian::Enquire::set_weighting_scheme(const Weight &weight_)
2964
2965        Parameters:
2966        -----------
2967
2968        weight_:  the new weighting scheme. If no weighting scheme is
2969        specified, the default is BM25 with the default parameters.
2970        """
2971        return _xapian.Enquire_set_weighting_scheme(self, *args)
2972
2973    def set_collapse_key(self, *args):
2974        """
2975        Set the collapse key to use for queries.
2976
2977        void Xapian::Enquire::set_collapse_key(Xapian::valueno collapse_key,
2978        Xapian::doccount collapse_max=1)
2979
2980        Parameters:
2981        -----------
2982
2983        collapse_key:  value number to collapse on - at most one MSet entry
2984        with each particular value will be returned (default is
2985        Xapian::BAD_VALUENO which means no collapsing).
2986
2987        collapse_max:  Max number of items with the same key to leave after
2988        collapsing (default 1).
2989
2990        The MSet returned by get_mset() will have only the "best" (at most)
2991        collapse_max entries with each particular value of collapse_key
2992        ("best" being highest ranked - i.e. highest weight or highest
2993        sorting key).
2994
2995        An example use might be to create a value for each document containing
2996        an MD5 hash of the document contents. Then duplicate documents from
2997        different sources can be eliminated at search time by collapsing with
2998        collapse_max = 1 (it's better to eliminate duplicates at index time,
2999        but this may not be always be possible - for example the search may be
3000        over more than one Xapian database).
3001
3002        Another use is to group matches in a particular category (e.g. you
3003        might collapse a mailing list search on the Subject: so that there's
3004        only one result per discussion thread). In this case you can use
3005        get_collapse_count() to give the user some idea how many other results
3006        there are. And if you index the Subject: as a boolean term as well as
3007        putting it in a value, you can offer a link to a non-collapsed search
3008        restricted to that thread using a boolean filter.
3009        """
3010        return _xapian.Enquire_set_collapse_key(self, *args)
3011
3012    ASCENDING = _xapian.Enquire_ASCENDING
3013    DESCENDING = _xapian.Enquire_DESCENDING
3014    DONT_CARE = _xapian.Enquire_DONT_CARE
3015    def set_docid_order(self, *args):
3016        """
3017        Set the direction in which documents are ordered by document id in the
3018        returned MSet.
3019
3020        void Xapian::Enquire::set_docid_order(docid_order order)
3021
3022        This order only has an effect on documents which would otherwise have
3023        equal rank. For a weighted probabilistic match with no sort value,
3024        this means documents with equal weight. For a boolean match, with no
3025        sort value, this means all documents. And if a sort value is used,
3026        this means documents with equal sort value (and also equal weight if
3027        ordering on relevance after the sort).
3028
3029        Parameters:
3030        -----------
3031
3032        order:  This can be: Xapian::Enquire::ASCENDING docids sort in
3033        ascending order (default)
3034
3035        Xapian::Enquire::DESCENDING docids sort in descending order
3036
3037        Xapian::Enquire::DONT_CARE docids sort in whatever order is most
3038        efficient for the backend
3039
3040        Note: If you add documents in strict date order, then a boolean search
3041        - i.e. set_weighting_scheme( Xapian::BoolWeight()) - with
3042        set_docid_order(Xapian::Enquire::DESCENDING) is an efficient way to
3043        perform "sort by date, newest first", and with
3044        set_docid_order(Xapian::Enquire::ASCENDING) a very efficient way to
3045        perform "sort by date, oldest first".
3046        """
3047        return _xapian.Enquire_set_docid_order(self, *args)
3048
3049    def set_cutoff(self, *args):
3050        """
3051        Set the percentage and/or weight cutoffs.
3052
3053        void Xapian::Enquire::set_cutoff(Xapian::percent percent_cutoff,
3054        Xapian::weight weight_cutoff=0)
3055
3056        Parameters:
3057        -----------
3058
3059        percent_cutoff:  Minimum percentage score for returned documents. If a
3060        document has a lower percentage score than this, it will not appear in
3061        the MSet. If your intention is to return only matches which contain
3062        all the terms in the query, then it's more efficient to use
3063        Xapian::Query::OP_AND instead of Xapian::Query::OP_OR in the query
3064        than to use set_cutoff(100). (default 0 => no percentage cut-off).
3065
3066        weight_cutoff:  Minimum weight for a document to be returned. If a
3067        document has a lower score that this, it will not appear in the MSet.
3068        It is usually only possible to choose an appropriate weight for cutoff
3069        based on the results of a previous run of the same query; this is thus
3070        mainly useful for alerting operations. The other potential use is with
3071        a user specified weighting scheme. (default 0 => no weight cut-off).
3072
3073        """
3074        return _xapian.Enquire_set_cutoff(self, *args)
3075
3076    def set_sort_by_relevance(self):
3077        """
3078        Set the sorting to be by relevance only.
3079
3080        void Xapian::Enquire::set_sort_by_relevance()
3081
3082        This is the default.
3083        """
3084        return _xapian.Enquire_set_sort_by_relevance(self)
3085
3086    def set_sort_by_value(self, *args):
3087        """
3088        void
3089        Xapian::Enquire::set_sort_by_value(Xapian::valueno sort_key)
3090        """
3091        return _xapian.Enquire_set_sort_by_value(self, *args)
3092
3093    def set_sort_by_value_then_relevance(self, *args):
3094        """
3095        void
3096        Xapian::Enquire::set_sort_by_value_then_relevance(Xapian::valueno
3097        sort_key)
3098        """
3099        return _xapian.Enquire_set_sort_by_value_then_relevance(self, *args)
3100
3101    def set_sort_by_relevance_then_value(self, *args):
3102        """
3103        void
3104        Xapian::Enquire::set_sort_by_relevance_then_value(Xapian::valueno
3105        sort_key)
3106        """
3107        return _xapian.Enquire_set_sort_by_relevance_then_value(self, *args)
3108
3109    def set_sort_by_key(self, *args):
3110        """
3111        void
3112        Xapian::Enquire::set_sort_by_key(Xapian::KeyMaker *sorter)
3113        """
3114        return _xapian.Enquire_set_sort_by_key(self, *args)
3115
3116    def set_sort_by_key_then_relevance(self, *args):
3117        """
3118        void
3119        Xapian::Enquire::set_sort_by_key_then_relevance(Xapian::KeyMaker
3120        *sorter)
3121        """
3122        return _xapian.Enquire_set_sort_by_key_then_relevance(self, *args)
3123
3124    def set_sort_by_relevance_then_key(self, *args):
3125        """
3126        void
3127        Xapian::Enquire::set_sort_by_relevance_then_key(Xapian::KeyMaker
3128        *sorter)
3129        """
3130        return _xapian.Enquire_set_sort_by_relevance_then_key(self, *args)
3131
3132    INCLUDE_QUERY_TERMS = _xapian.Enquire_INCLUDE_QUERY_TERMS
3133    USE_EXACT_TERMFREQ = _xapian.Enquire_USE_EXACT_TERMFREQ
3134    def get_eset(self, *args):
3135        """
3136        Get the expand set for the given rset.
3137
3138        ESet Xapian::Enquire::get_eset(Xapian::termcount maxitems, const RSet
3139        &omrset, int flags, double k, const Xapian::ExpandDecider *edecider,
3140        Xapian::weight min_wt) const
3141
3142        Parameters:
3143        -----------
3144
3145        maxitems:  the maximum number of items to return.
3146
3147        omrset:  the relevance set to use when performing the expand
3148        operation.
3149
3150        flags:  zero or more of these values |-ed together:
3151        Xapian::Enquire::INCLUDE_QUERY_TERMS query terms may be returned from
3152        expand
3153
3154        Xapian::Enquire::USE_EXACT_TERMFREQ for multi dbs, calculate the exact
3155        termfreq; otherwise an approximation is used which can greatly improve
3156        efficiency, but still returns good results.
3157
3158        k:  the parameter k in the query expansion algorithm (default is 1.0)
3159
3160        edecider:  a decision functor to use to decide whether a given term
3161        should be put in the ESet
3162
3163        min_wt:  the minimum weight for included terms
3164
3165        An ESet object containing the results of the expand.
3166
3167        Parameters:
3168        -----------
3169
3170        Xapian::InvalidArgumentError:  See class documentation.
3171        """
3172        return _xapian.Enquire_get_eset(self, *args)
3173
3174    def get_matching_terms_begin(self, *args):
3175        """
3176        Get terms which match a given document, by match set item.
3177
3178        TermIterator Xapian::Enquire::get_matching_terms_begin(const
3179        MSetIterator &it) const
3180
3181        This method returns the terms in the current query which match the
3182        given document.
3183
3184        If the underlying database has suitable support, using this call
3185        (rather than passing a Xapian::docid) will enable the system to ensure
3186        that the correct data is returned, and that the document has not been
3187        deleted or changed since the query was performed.
3188
3189        Parameters:
3190        -----------
3191
3192        it:  The iterator for which to retrieve the matching terms.
3193
3194        An iterator returning the terms which match the document. The terms
3195        will be returned (as far as this makes any sense) in the same order as
3196        the terms in the query. Terms will not occur more than once, even if
3197        they do in the query.
3198
3199        Parameters:
3200        -----------
3201
3202        Xapian::InvalidArgumentError:  See class documentation.
3203
3204        Xapian::DocNotFoundError:  The document specified could not be found
3205        in the database.
3206        """
3207        return _xapian.Enquire_get_matching_terms_begin(self, *args)
3208
3209    def get_matching_terms_end(self, *args):
3210        """
3211        End iterator corresponding to get_matching_terms_begin()
3212
3213        TermIterator Xapian::Enquire::get_matching_terms_end(const
3214        MSetIterator &) const
3215        """
3216        return _xapian.Enquire_get_matching_terms_end(self, *args)
3217
3218    def __str__(self):
3219        """
3220        Return a string describing this object.
3221
3222        std::string Xapian::Enquire::get_description() const
3223        """
3224        return _xapian.Enquire___str__(self)
3225
3226Enquire.set_query = new_instancemethod(_xapian.Enquire_set_query,None,Enquire)
3227Enquire.get_query = new_instancemethod(_xapian.Enquire_get_query,None,Enquire)
3228Enquire.add_matchspy = new_instancemethod(_xapian.Enquire_add_matchspy,None,Enquire)
3229Enquire.clear_matchspies = new_instancemethod(_xapian.Enquire_clear_matchspies,None,Enquire)
3230Enquire.set_weighting_scheme = new_instancemethod(_xapian.Enquire_set_weighting_scheme,None,Enquire)
3231Enquire.set_collapse_key = new_instancemethod(_xapian.Enquire_set_collapse_key,None,Enquire)
3232Enquire.set_docid_order = new_instancemethod(_xapian.Enquire_set_docid_order,None,Enquire)
3233Enquire.set_cutoff = new_instancemethod(_xapian.Enquire_set_cutoff,None,Enquire)
3234Enquire.set_sort_by_relevance = new_instancemethod(_xapian.Enquire_set_sort_by_relevance,None,Enquire)
3235Enquire.set_sort_by_value = new_instancemethod(_xapian.Enquire_set_sort_by_value,None,Enquire)
3236Enquire.set_sort_by_value_then_relevance = new_instancemethod(_xapian.Enquire_set_sort_by_value_then_relevance,None,Enquire)
3237Enquire.set_sort_by_relevance_then_value = new_instancemethod(_xapian.Enquire_set_sort_by_relevance_then_value,None,Enquire)
3238Enquire.set_sort_by_key = new_instancemethod(_xapian.Enquire_set_sort_by_key,None,Enquire)
3239Enquire.set_sort_by_key_then_relevance = new_instancemethod(_xapian.Enquire_set_sort_by_key_then_relevance,None,Enquire)
3240Enquire.set_sort_by_relevance_then_key = new_instancemethod(_xapian.Enquire_set_sort_by_relevance_then_key,None,Enquire)
3241Enquire.get_mset = new_instancemethod(_xapian.Enquire_get_mset,None,Enquire)
3242Enquire.get_eset = new_instancemethod(_xapian.Enquire_get_eset,None,Enquire)
3243Enquire.get_matching_terms_begin = new_instancemethod(_xapian.Enquire_get_matching_terms_begin,None,Enquire)
3244Enquire.get_matching_terms_end = new_instancemethod(_xapian.Enquire_get_matching_terms_end,None,Enquire)
3245Enquire.__str__ = new_instancemethod(_xapian.Enquire___str__,None,Enquire)
3246Enquire_swigregister = _xapian.Enquire_swigregister
3247Enquire_swigregister(Enquire)
3248
3249class Registry(object):
3250    """
3251    Registry for user subclasses.
3252
3253    This class provides a way for the remote server to look up user
3254    subclasses when unserialising.
3255    """
3256    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
3257    __repr__ = _swig_repr
3258    def __init__(self, *args):
3259        """
3260        Default constructor.
3261
3262        Xapian::Registry::Registry()
3263
3264        The registry will contain all standard subclasses of user-subclassable
3265        classes.
3266        """
3267        _xapian.Registry_swiginit(self,_xapian.new_Registry(*args))
3268    __swig_destroy__ = _xapian.delete_Registry
3269    def register_weighting_scheme(self, *args):
3270        """
3271        Register a weighting scheme.
3272
3273        void Xapian::Registry::register_weighting_scheme(const Xapian::Weight
3274        &wt)
3275
3276        Parameters:
3277        -----------
3278
3279        wt:  The weighting scheme to register.
3280        """
3281        return _xapian.Registry_register_weighting_scheme(self, *args)
3282
3283    def get_weighting_scheme(self, *args):
3284        """
3285        Get the weighting scheme given a name.
3286
3287        const Xapian::Weight* Xapian::Registry::get_weighting_scheme(const
3288        std::string &name) const
3289
3290        Parameters:
3291        -----------
3292
3293        name:  The name of the weighting scheme to find.
3294
3295        An object with the requested name, or NULL if the weighting scheme
3296        could not be found. The returned object is owned by the registry and
3297        so must not be deleted by the caller.
3298        """
3299        return _xapian.Registry_get_weighting_scheme(self, *args)
3300
3301    def register_posting_source(self, *args):
3302        """
3303        Register a user-defined posting source class.
3304
3305        void Xapian::Registry::register_posting_source(const
3306        Xapian::PostingSource &source)
3307
3308        Parameters:
3309        -----------
3310
3311        source:  The posting source to register.
3312        """
3313        return _xapian.Registry_register_posting_source(self, *args)
3314
3315    def get_posting_source(self, *args):
3316        """
3317        Get a posting source given a name.
3318
3319        const Xapian::PostingSource*
3320        Xapian::Registry::get_posting_source(const std::string &name) const
3321
3322        Parameters:
3323        -----------
3324
3325        name:  The name of the posting source to find.
3326
3327        An object with the requested name, or NULL if the posting source could
3328        not be found. The returned object is owned by the registry and so must
3329        not be deleted by the caller.
3330        """
3331        return _xapian.Registry_get_posting_source(self, *args)
3332
3333    def register_match_spy(self, *args):
3334        """
3335        Register a user-defined match spy class.
3336
3337        void Xapian::Registry::register_match_spy(const Xapian::MatchSpy &spy)
3338
3339        Parameters:
3340        -----------
3341
3342        spy:  The match spy to register.
3343        """
3344        return _xapian.Registry_register_match_spy(self, *args)
3345
3346    def get_match_spy(self, *args):
3347        """
3348        Get a match spy given a name.
3349
3350        const Xapian::MatchSpy* Xapian::Registry::get_match_spy(const
3351        std::string &name) const
3352
3353        Parameters:
3354        -----------
3355
3356        name:  The name of the match spy to find.
3357
3358        An object with the requested name, or NULL if the match spy could not
3359        be found. The returned object is owned by the registry and so must not
3360        be deleted by the caller.
3361        """
3362        return _xapian.Registry_get_match_spy(self, *args)
3363
3364Registry.register_weighting_scheme = new_instancemethod(_xapian.Registry_register_weighting_scheme,None,Registry)
3365Registry.get_weighting_scheme = new_instancemethod(_xapian.Registry_get_weighting_scheme,None,Registry)
3366Registry.register_posting_source = new_instancemethod(_xapian.Registry_register_posting_source,None,Registry)
3367Registry.get_posting_source = new_instancemethod(_xapian.Registry_get_posting_source,None,Registry)
3368Registry.register_match_spy = new_instancemethod(_xapian.Registry_register_match_spy,None,Registry)
3369Registry.get_match_spy = new_instancemethod(_xapian.Registry_get_match_spy,None,Registry)
3370Registry_swigregister = _xapian.Registry_swigregister
3371Registry_swigregister(Registry)
3372
3373class Weight(object):
3374    """
3375    Abstract base class for weighting schemes.
3376    """
3377    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
3378    def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract")
3379    __repr__ = _swig_repr
3380    __swig_destroy__ = _xapian.delete_Weight
3381    def name(self):
3382        """
3383        Return the name of this weighting scheme.
3384
3385        virtual std::string Xapian::Weight::name() const
3386
3387        This name is used by the remote backend. It is passed along with the
3388        serialised parameters to the remote server so that it knows which
3389        class to create.
3390
3391        Return the full namespace-qualified name of your class here - if your
3392        class is called FooWeight, return "FooWeight" from this method (
3393        Xapian::BM25Weight returns "Xapian::BM25Weight" here).
3394
3395        If you don't want to support the remote backend, you can use the
3396        default implementation which simply returns an empty string.
3397        """
3398        return _xapian.Weight_name(self)
3399
3400    def get_sumpart(self, *args):
3401        """
3402        Calculate the weight contribution for this object's term to a
3403        document.
3404
3405        virtual Xapian::weight Xapian::Weight::get_sumpart(Xapian::termcount
3406        wdf, Xapian::termcount doclen) const =0
3407
3408        The parameters give information about the document which may be used
3409        in the calculations:
3410
3411        Parameters:
3412        -----------
3413
3414        wdf:  The within document frequency of the term in the document.
3415
3416        doclen:  The document's length (unnormalised).
3417        """
3418        return _xapian.Weight_get_sumpart(self, *args)
3419
3420    def get_maxpart(self):
3421        """
3422        Return an upper bound on what get_sumpart() can return for any
3423        document.
3424
3425        virtual Xapian::weight Xapian::Weight::get_maxpart() const =0
3426
3427        This information is used by the matcher to perform various
3428        optimisations, so strive to make the bound as tight as possible.
3429        """
3430        return _xapian.Weight_get_maxpart(self)
3431
3432    def get_sumextra(self, *args):
3433        """
3434        Calculate the term-independent weight component for a document.
3435
3436        virtual Xapian::weight Xapian::Weight::get_sumextra(Xapian::termcount
3437        doclen) const =0
3438
3439        The parameter gives information about the document which may be used
3440        in the calculations:
3441
3442        Parameters:
3443        -----------
3444
3445        doclen:  The document's length (unnormalised).
3446        """
3447        return _xapian.Weight_get_sumextra(self, *args)
3448
3449    def get_maxextra(self):
3450        """
3451        Return an upper bound on what get_sumextra() can return for any
3452        document.
3453
3454        virtual Xapian::weight Xapian::Weight::get_maxextra() const =0
3455
3456        This information is used by the matcher to perform various
3457        optimisations, so strive to make the bound as tight as possible.
3458        """
3459        return _xapian.Weight_get_maxextra(self)
3460
3461Weight.name = new_instancemethod(_xapian.Weight_name,None,Weight)
3462Weight.get_sumpart = new_instancemethod(_xapian.Weight_get_sumpart,None,Weight)
3463Weight.get_maxpart = new_instancemethod(_xapian.Weight_get_maxpart,None,Weight)
3464Weight.get_sumextra = new_instancemethod(_xapian.Weight_get_sumextra,None,Weight)
3465Weight.get_maxextra = new_instancemethod(_xapian.Weight_get_maxextra,None,Weight)
3466Weight_swigregister = _xapian.Weight_swigregister
3467Weight_swigregister(Weight)
3468
3469class BoolWeight(Weight):
3470    """
3471    Class implementing a "boolean" weighting scheme.
3472
3473    This weighting scheme gives all documents zero weight.
3474    """
3475    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
3476    __repr__ = _swig_repr
3477    def __init__(self):
3478        """
3479        Construct a BoolWeight.
3480
3481        Xapian::BoolWeight::BoolWeight()
3482        """
3483        _xapian.BoolWeight_swiginit(self,_xapian.new_BoolWeight())
3484    __swig_destroy__ = _xapian.delete_BoolWeight
3485BoolWeight_swigregister = _xapian.BoolWeight_swigregister
3486BoolWeight_swigregister(BoolWeight)
3487
3488class BM25Weight(Weight):
3489    """
3490    Xapian::Weight subclass implementing the BM25 probabilistic formula.
3491
3492    """
3493    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
3494    __repr__ = _swig_repr
3495    def __init__(self, *args):
3496        """Xapian::BM25Weight::BM25Weight() """
3497        _xapian.BM25Weight_swiginit(self,_xapian.new_BM25Weight(*args))
3498    __swig_destroy__ = _xapian.delete_BM25Weight
3499BM25Weight_swigregister = _xapian.BM25Weight_swigregister
3500BM25Weight_swigregister(BM25Weight)
3501
3502class TradWeight(Weight):
3503    """
3504    Xapian::Weight subclass implementing the traditional probabilistic
3505    formula.
3506
3507    This class implements the "traditional" Probabilistic Weighting
3508    scheme, as described by the early papers on Probabilistic Retrieval.
3509    BM25 generally gives better results.
3510
3511    TradWeight(k) is equivalent to BM25Weight(k, 0, 0, 1, 0), except that
3512    the latter returns weights (k+1) times larger.
3513    """
3514    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
3515    __repr__ = _swig_repr
3516    def __init__(self, k=1.0):
3517        """
3518        Construct a TradWeight.
3519
3520        Xapian::TradWeight::TradWeight(double k=1.0)
3521
3522        Parameters:
3523        -----------
3524
3525        k:  A non-negative parameter controlling how influential within-
3526        document- frequency (wdf) and document length are. k=0 means that wdf
3527        and document length don't affect the weights. The larger k is, the
3528        more they do. (default 1)
3529        """
3530        _xapian.TradWeight_swiginit(self,_xapian.new_TradWeight(k))
3531    __swig_destroy__ = _xapian.delete_TradWeight
3532TradWeight_swigregister = _xapian.TradWeight_swigregister
3533TradWeight_swigregister(TradWeight)
3534
3535class MatchSpy(object):
3536    """
3537    Abstract base class for match spies.
3538
3539    The subclasses will generally accumulate information seen during the
3540    match, to calculate aggregate functions, or other profiles of the
3541    matching documents.
3542    """
3543    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
3544    __repr__ = _swig_repr
3545    def __init__(self):
3546        if self.__class__ == MatchSpy:
3547            _self = None
3548        else:
3549            _self = self
3550        _xapian.MatchSpy_swiginit(self,_xapian.new_MatchSpy(_self, ))
3551    __swig_destroy__ = _xapian.delete_MatchSpy
3552    def name(self):
3553        """
3554        Return the name of this match spy.
3555
3556        virtual std::string Xapian::MatchSpy::name() const
3557
3558        This name is used by the remote backend. It is passed with the
3559        serialised parameters to the remote server so that it knows which
3560        class to create.
3561
3562        Return the full namespace-qualified name of your class here - if your
3563        class is called MyApp::FooMatchSpy, return "MyApp::FooMatchSpy" from
3564        this method.
3565
3566        If you don't want to support the remote backend in your match spy, you
3567        can use the default implementation which simply throws
3568        Xapian::UnimplementedError.
3569        """
3570        return _xapian.MatchSpy_name(self)
3571
3572    def merge_results(self, *args):
3573        """
3574        Unserialise some results, and merge them into this matchspy.
3575
3576        virtual void Xapian::MatchSpy::merge_results(const std::string &s)
3577
3578        The order in which results are merged should not be significant, since
3579        this order is not specified (and will vary depending on the speed of
3580        the search in each sub-database).
3581
3582        If you don't want to support the remote backend in your match spy, you
3583        can use the default implementation which simply throws
3584        Xapian::UnimplementedError.
3585
3586        Parameters:
3587        -----------
3588
3589        s:  A string containing the serialised results.
3590        """
3591        return _xapian.MatchSpy_merge_results(self, *args)
3592
3593    def __str__(self):
3594        """
3595        Return a string describing this object.
3596
3597        virtual std::string Xapian::MatchSpy::get_description() const
3598
3599        This default implementation returns a generic answer, to avoid forcing
3600        those deriving their own MatchSpy subclasses from having to implement
3601        this (they may not care what get_description() gives for their
3602        subclass).
3603        """
3604        return _xapian.MatchSpy___str__(self)
3605
3606    def __disown__(self):
3607        self.this.disown()
3608        _xapian.disown_MatchSpy(self)
3609        return weakref_proxy(self)
3610MatchSpy.__call__ = new_instancemethod(_xapian.MatchSpy___call__,None,MatchSpy)
3611MatchSpy.name = new_instancemethod(_xapian.MatchSpy_name,None,MatchSpy)
3612MatchSpy.merge_results = new_instancemethod(_xapian.MatchSpy_merge_results,None,MatchSpy)
3613MatchSpy.__str__ = new_instancemethod(_xapian.MatchSpy___str__,None,MatchSpy)
3614MatchSpy_swigregister = _xapian.MatchSpy_swigregister
3615MatchSpy_swigregister(MatchSpy)
3616
3617class ValueCountMatchSpy(MatchSpy):
3618    """
3619    Class for counting the frequencies of values in the matching
3620    documents.
3621    """
3622    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
3623    __repr__ = _swig_repr
3624    def __init__(self, *args):
3625        """
3626        Construct a MatchSpy which counts the values in a particular slot.
3627
3628        Xapian::ValueCountMatchSpy::ValueCountMatchSpy(Xapian::valueno slot_)
3629
3630        """
3631        _xapian.ValueCountMatchSpy_swiginit(self,_xapian.new_ValueCountMatchSpy(*args))
3632    def get_total(self):
3633        """
3634        Return the total number of documents tallied.
3635
3636        size_t Xapian::ValueCountMatchSpy::get_total() const
3637        """
3638        return _xapian.ValueCountMatchSpy_get_total(self)
3639
3640    def values_begin(self):
3641        """
3642        Get an iterator over the values seen in the slot.
3643
3644        TermIterator Xapian::ValueCountMatchSpy::values_begin() const
3645
3646        Items will be returned in ascending alphabetical order.
3647
3648        During the iteration, the frequency of the current value can be
3649        obtained with the get_termfreq() method on the iterator.
3650        """
3651        return _xapian.ValueCountMatchSpy_values_begin(self)
3652
3653    def values_end(self):
3654        """
3655        End iterator corresponding to values_begin()
3656
3657        TermIterator Xapian::ValueCountMatchSpy::values_end() const
3658        """
3659        return _xapian.ValueCountMatchSpy_values_end(self)
3660
3661    def top_values_begin(self, *args):
3662        """
3663        Get an iterator over the most frequent values seen in the slot.
3664
3665        TermIterator Xapian::ValueCountMatchSpy::top_values_begin(size_t
3666        maxvalues) const
3667
3668        Items will be returned in descending order of frequency. Values with
3669        the same frequency will be returned in ascending alphabetical order.
3670
3671        During the iteration, the frequency of the current value can be
3672        obtained with the get_termfreq() method on the iterator.
3673
3674        Parameters:
3675        -----------
3676
3677        maxvalues:  The maximum number of values to return.
3678        """
3679        return _xapian.ValueCountMatchSpy_top_values_begin(self, *args)
3680
3681    def top_values_end(self, *args):
3682        """
3683        End iterator corresponding to top_values_begin()
3684
3685        TermIterator Xapian::ValueCountMatchSpy::top_values_end(size_t) const
3686
3687        """
3688        return _xapian.ValueCountMatchSpy_top_values_end(self, *args)
3689
3690    __swig_destroy__ = _xapian.delete_ValueCountMatchSpy
3691ValueCountMatchSpy.get_total = new_instancemethod(_xapian.ValueCountMatchSpy_get_total,None,ValueCountMatchSpy)
3692ValueCountMatchSpy.values_begin = new_instancemethod(_xapian.ValueCountMatchSpy_values_begin,None,ValueCountMatchSpy)
3693ValueCountMatchSpy.values_end = new_instancemethod(_xapian.ValueCountMatchSpy_values_end,None,ValueCountMatchSpy)
3694ValueCountMatchSpy.top_values_begin = new_instancemethod(_xapian.ValueCountMatchSpy_top_values_begin,None,ValueCountMatchSpy)
3695ValueCountMatchSpy.top_values_end = new_instancemethod(_xapian.ValueCountMatchSpy_top_values_end,None,ValueCountMatchSpy)
3696ValueCountMatchSpy_swigregister = _xapian.ValueCountMatchSpy_swigregister
3697ValueCountMatchSpy_swigregister(ValueCountMatchSpy)
3698
3699class Database(object):
3700    """
3701    This class is used to access a database, or a group of databases.
3702
3703    For searching, this class is used in conjunction with an Enquire
3704    object.
3705
3706    Parameters:
3707    -----------
3708
3709    InvalidArgumentError:  will be thrown if an invalid argument is
3710    supplied, for example, an unknown database type.
3711
3712    DatabaseOpeningError:  may be thrown if the database cannot be opened
3713    (for example, a required file cannot be found).
3714
3715    DatabaseVersionError:  may be thrown if the database is in an
3716    unsupported format (for example, created by a newer version of Xapian
3717    which uses an incompatible format).
3718    """
3719    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
3720    __repr__ = _swig_repr
3721    def add_database(self, *args):
3722        """
3723        Add an existing database (or group of databases) to those accessed by
3724        this object.
3725
3726        void Xapian::Database::add_database(const Database &database)
3727
3728        Parameters:
3729        -----------
3730
3731        database:  the database(s) to add.
3732        """
3733        return _xapian.Database_add_database(self, *args)
3734
3735    __swig_destroy__ = _xapian.delete_Database
3736    def __init__(self, *args):
3737        """
3738        Copying is allowed.
3739
3740        Xapian::Database::Database(const Database &other)
3741
3742        The internals are reference counted, so copying is cheap.
3743
3744        Parameters:
3745        -----------
3746
3747        other:  The object to copy.
3748        """
3749        _xapian.Database_swiginit(self,_xapian.new_Database(*args))
3750    def reopen(self):
3751        """
3752        Re-open the database.
3753
3754        void Xapian::Database::reopen()
3755
3756        This re-opens the database(s) to the latest available version(s). It
3757        can be used either to make sure the latest results are returned, or to
3758        recover from a Xapian::DatabaseModifiedError.
3759
3760        Calling reopen() on a database which has been closed (with  close())
3761        will always raise a Xapian::DatabaseError.
3762        """
3763        return _xapian.Database_reopen(self)
3764
3765    def close(self):
3766        """
3767        Close the database.
3768
3769        virtual void Xapian::Database::close()
3770
3771        This closes the database and closes all its file handles.
3772
3773        For a WritableDatabase, if a transaction is active it will be aborted,
3774        while if no transaction is active commit() will be implicitly called.
3775        Also the write lock is released.
3776
3777        Closing a database cannot be undone - in particular, calling reopen()
3778        after close() will not reopen it, but will instead throw a
3779        Xapian::DatabaseError exception.
3780
3781        Calling close() again on a database which has already been closed has
3782        no effect (and doesn't raise an exception).
3783
3784        After close() has been called, calls to other methods of the database,
3785        and to methods of other objects associated with the database, will
3786        either:
3787
3788        behave exactly as they would have done if the database had not been
3789        closed (this can only happen if all the required data is cached)
3790
3791        raise a Xapian::DatabaseError exception indicating that the database
3792        is closed.
3793
3794        The reason for this behaviour is that otherwise we'd have to check
3795        that the database is still open on every method call on every object
3796        associated with a Database, when in many cases they are working on
3797        data which has already been loaded and so they are able to just behave
3798        correctly.
3799
3800        This method was added in Xapian 1.1.0.
3801        """
3802        return _xapian.Database_close(self)
3803
3804    def __str__(self):
3805        """
3806        Return a string describing this object.
3807
3808        virtual std::string Xapian::Database::get_description() const
3809        """
3810        return _xapian.Database___str__(self)
3811
3812    def postlist_begin(self, *args):
3813        """
3814        An iterator pointing to the start of the postlist for a given term.
3815
3816        PostingIterator Xapian::Database::postlist_begin(const std::string
3817        &tname) const
3818
3819        Parameters:
3820        -----------
3821
3822        tname:  The termname to iterate postings for. If the term name is the
3823        empty string, the iterator returned will list all the documents in the
3824        database. Such an iterator will always return a WDF value of 1, since
3825        there is no obvious meaning for this quantity in this case.
3826        """
3827        return _xapian.Database_postlist_begin(self, *args)
3828
3829    def postlist_end(self, *args):
3830        """
3831        Corresponding end iterator to postlist_begin().
3832
3833        PostingIterator Xapian::Database::postlist_end(const std::string &)
3834        const
3835        """
3836        return _xapian.Database_postlist_end(self, *args)
3837
3838    def termlist_begin(self, *args):
3839        """
3840        An iterator pointing to the start of the termlist for a given
3841        document.
3842
3843        TermIterator Xapian::Database::termlist_begin(Xapian::docid did) const
3844
3845        Parameters:
3846        -----------
3847
3848        did:  The document id of the document to iterate terms for.
3849        """
3850        return _xapian.Database_termlist_begin(self, *args)
3851
3852    def termlist_end(self, *args):
3853        """
3854        Corresponding end iterator to termlist_begin().
3855
3856        TermIterator Xapian::Database::termlist_end(Xapian::docid) const
3857        """
3858        return _xapian.Database_termlist_end(self, *args)
3859
3860    def positionlist_begin(self, *args):
3861        """
3862        An iterator pointing to the start of the position list for a given
3863        term in a given document.
3864
3865        PositionIterator Xapian::Database::positionlist_begin(Xapian::docid
3866        did, const std::string &tname) const
3867        """
3868        return _xapian.Database_positionlist_begin(self, *args)
3869
3870    def positionlist_end(self, *args):
3871        """
3872        Corresponding end iterator to positionlist_begin().
3873
3874        PositionIterator Xapian::Database::positionlist_end(Xapian::docid,
3875        const std::string &) const
3876        """
3877        return _xapian.Database_positionlist_end(self, *args)
3878
3879    def allterms_begin(self, *args):
3880        """
3881        An iterator which runs across all terms with a given prefix.
3882
3883        TermIterator Xapian::Database::allterms_begin(const std::string
3884        &prefix) const
3885
3886        This is functionally similar to getting an iterator with
3887        allterms_begin() and then calling skip_to(prefix) on that iterator to
3888        move to the start of the prefix, but is more convenient (because it
3889        detects the end of the prefixed terms), and may be more efficient than
3890        simply calling skip_to() after opening the iterator, particularly for
3891        remote databases.
3892
3893        Parameters:
3894        -----------
3895
3896        prefix:  The prefix to restrict the returned terms to.
3897        """
3898        return _xapian.Database_allterms_begin(self, *args)
3899
3900    def allterms_end(self, *args):
3901        """
3902        Corresponding end iterator to allterms_begin(prefix).
3903
3904        TermIterator Xapian::Database::allterms_end(const std::string &) const
3905
3906        """
3907        return _xapian.Database_allterms_end(self, *args)
3908
3909    def get_doccount(self):
3910        """
3911        Get the number of documents in the database.
3912
3913        Xapian::doccount Xapian::Database::get_doccount() const
3914        """
3915        return _xapian.Database_get_doccount(self)
3916
3917    def get_lastdocid(self):
3918        """
3919        Get the highest document id which has been used in the database.
3920
3921        Xapian::docid Xapian::Database::get_lastdocid() const
3922        """
3923        return _xapian.Database_get_lastdocid(self)
3924
3925    def get_avlength(self):
3926        """
3927        Get the average length of the documents in the database.
3928
3929        Xapian::doclength Xapian::Database::get_avlength() const
3930        """
3931        return _xapian.Database_get_avlength(self)
3932
3933    def get_termfreq(self, *args):
3934        """
3935        Get the number of documents in the database indexed by a given term.
3936
3937        Xapian::doccount Xapian::Database::get_termfreq(const std::string
3938        &tname) const
3939        """
3940        return _xapian.Database_get_termfreq(self, *args)
3941
3942    def term_exists(self, *args):
3943        """
3944        Check if a given term exists in the database.
3945
3946        bool Xapian::Database::term_exists(const std::string &tname) const
3947
3948        Parameters:
3949        -----------
3950
3951        tname:  The term to test the existence of.
3952
3953        true if and only if the term exists in the database. This is the same
3954        as (get_termfreq(tname) != 0), but will often be more efficient.
3955        """
3956        return _xapian.Database_term_exists(self, *args)
3957
3958    def get_collection_freq(self, *args):
3959        """
3960        Return the total number of occurrences of the given term.
3961
3962        Xapian::termcount Xapian::Database::get_collection_freq(const
3963        std::string &tname) const
3964
3965        This is the sum of the number of occurrences of the term in each
3966        document it indexes: i.e., the sum of the within document frequencies
3967        of the term.
3968
3969        Parameters:
3970        -----------
3971
3972        tname:  The term whose collection frequency is being requested.
3973        """
3974        return _xapian.Database_get_collection_freq(self, *args)
3975
3976    def get_value_freq(self, *args):
3977        """
3978        Return the frequency of a given value slot.
3979
3980        Xapian::doccount Xapian::Database::get_value_freq(Xapian::valueno
3981        slot) const
3982
3983        This is the number of documents which have a (non-empty) value stored
3984        in the slot.
3985
3986        Parameters:
3987        -----------
3988
3989        slot:  The value slot to examine.
3990
3991        Parameters:
3992        -----------
3993
3994        UnimplementedError:  The frequency of the value isn't available for
3995        this database type.
3996        """
3997        return _xapian.Database_get_value_freq(self, *args)
3998
3999    def get_value_lower_bound(self, *args):
4000        """
4001        Get a lower bound on the values stored in the given value slot.
4002
4003        std::string Xapian::Database::get_value_lower_bound(Xapian::valueno
4004        slot) const
4005
4006        If there are no values stored in the given value slot, this will
4007        return an empty string.
4008
4009        If the lower bound isn't available for the given database type, this
4010        will return the lowest possible bound - the empty string.
4011
4012        Parameters:
4013        -----------
4014
4015        slot:  The value slot to examine.
4016        """
4017        return _xapian.Database_get_value_lower_bound(self, *args)
4018
4019    def get_value_upper_bound(self, *args):
4020        """
4021        Get an upper bound on the values stored in the given value slot.
4022
4023        std::string Xapian::Database::get_value_upper_bound(Xapian::valueno
4024        slot) const
4025
4026        If there are no values stored in the given value slot, this will
4027        return an empty string.
4028
4029        Parameters:
4030        -----------
4031
4032        slot:  The value slot to examine.
4033
4034        Parameters:
4035        -----------
4036
4037        UnimplementedError:  The upper bound of the values isn't available for
4038        this database type.
4039        """
4040        return _xapian.Database_get_value_upper_bound(self, *args)
4041
4042    def get_doclength_lower_bound(self):
4043        """
4044        Get a lower bound on the length of a document in this DB.
4045
4046        Xapian::termcount Xapian::Database::get_doclength_lower_bound() const
4047
4048        This bound does not include any zero-length documents.
4049        """
4050        return _xapian.Database_get_doclength_lower_bound(self)
4051
4052    def get_doclength_upper_bound(self):
4053        """
4054        Get an upper bound on the length of a document in this DB.
4055
4056        Xapian::termcount Xapian::Database::get_doclength_upper_bound() const
4057
4058        """
4059        return _xapian.Database_get_doclength_upper_bound(self)
4060
4061    def get_wdf_upper_bound(self, *args):
4062        """
4063        Get an upper bound on the wdf of term term.
4064
4065        Xapian::termcount Xapian::Database::get_wdf_upper_bound(const
4066        std::string &term) const
4067        """
4068        return _xapian.Database_get_wdf_upper_bound(self, *args)
4069
4070    def valuestream_begin(self, *args):
4071        """
4072        Return an iterator over the value in slot slot for each document.
4073
4074        ValueIterator Xapian::Database::valuestream_begin(Xapian::valueno
4075        slot) const
4076        """
4077        return _xapian.Database_valuestream_begin(self, *args)
4078
4079    def valuestream_end(self, *args):
4080        """
4081        Return end iterator corresponding to valuestream_begin().
4082
4083        ValueIteratorEnd_ Xapian::Database::valuestream_end(Xapian::valueno)
4084        const
4085        """
4086        return _xapian.Database_valuestream_end(self, *args)
4087
4088    def get_doclength(self, *args):
4089        """
4090        Get the length of a document.
4091
4092        Xapian::termcount Xapian::Database::get_doclength(Xapian::docid did)
4093        const
4094        """
4095        return _xapian.Database_get_doclength(self, *args)
4096
4097    def keep_alive(self):
4098        """
4099        Send a "keep-alive" to remote databases to stop them timing out.
4100
4101        void Xapian::Database::keep_alive()
4102
4103        Has no effect on non-remote databases.
4104        """
4105        return _xapian.Database_keep_alive(self)
4106
4107    def get_document(self, *args):
4108        """
4109        Get a document from the database, given its document id.
4110
4111        Xapian::Document Xapian::Database::get_document(Xapian::docid did)
4112        const
4113
4114        This method returns a Xapian::Document object which provides the
4115        information about a document.
4116
4117        Parameters:
4118        -----------
4119
4120        did:  The document id of the document to retrieve.
4121
4122        A Xapian::Document object containing the document data
4123
4124        Parameters:
4125        -----------
4126
4127        Xapian::DocNotFoundError:  The document specified could not be found
4128        in the database.
4129
4130        Xapian::InvalidArgumentError:  did was 0, which is not a valid
4131        document id.
4132        """
4133        return _xapian.Database_get_document(self, *args)
4134
4135    def get_spelling_suggestion(self, *args):
4136        """
4137        Suggest a spelling correction.
4138
4139        std::string Xapian::Database::get_spelling_suggestion(const
4140        std::string &word, unsigned max_edit_distance=2) const
4141
4142        Parameters:
4143        -----------
4144
4145        word:  The potentially misspelled word.
4146
4147        max_edit_distance:  Only consider words which are at most
4148        max_edit_distance edits from word. An edit is a character insertion,
4149        deletion, or the transposition of two adjacent characters (default is
4150        2).
4151        """
4152        return _xapian.Database_get_spelling_suggestion(self, *args)
4153
4154    def spellings_begin(self):
4155        """
4156        An iterator which returns all the spelling correction targets.
4157
4158        Xapian::TermIterator Xapian::Database::spellings_begin() const
4159
4160        This returns all the words which are considered as targets for the
4161        spelling correction algorithm. The frequency of each word is available
4162        as the term frequency of each entry in the returned iterator.
4163        """
4164        return _xapian.Database_spellings_begin(self)
4165
4166    def spellings_end(self):
4167        """
4168        Corresponding end iterator to spellings_begin().
4169
4170        Xapian::TermIterator Xapian::Database::spellings_end() const
4171        """
4172        return _xapian.Database_spellings_end(self)
4173
4174    def synonyms_begin(self, *args):
4175        """
4176        An iterator which returns all the synonyms for a given term.
4177
4178        Xapian::TermIterator Xapian::Database::synonyms_begin(const
4179        std::string &term) const
4180
4181        Parameters:
4182        -----------
4183
4184        term:  The term to return synonyms for.
4185        """
4186        return _xapian.Database_synonyms_begin(self, *args)
4187
4188    def synonyms_end(self, *args):
4189        """
4190        Corresponding end iterator to synonyms_begin(term).
4191
4192        Xapian::TermIterator Xapian::Database::synonyms_end(const std::string
4193        &) const
4194        """
4195        return _xapian.Database_synonyms_end(self, *args)
4196
4197    def synonym_keys_begin(self, prefix=""):
4198        """
4199        An iterator which returns all terms which have synonyms.
4200
4201        Xapian::TermIterator Xapian::Database::synonym_keys_begin(const
4202        std::string &prefix=std::string()) const
4203
4204        Parameters:
4205        -----------
4206
4207        prefix:  If non-empty, only terms with this prefix are returned.
4208        """
4209        return _xapian.Database_synonym_keys_begin(self, prefix)
4210
4211    def synonym_keys_end(self, prefix=""):
4212        """
4213        Corresponding end iterator to synonym_keys_begin(prefix).
4214
4215        Xapian::TermIterator Xapian::Database::synonym_keys_end(const
4216        std::string &=std::string()) const
4217        """
4218        return _xapian.Database_synonym_keys_end(self, prefix)
4219
4220    def get_metadata(self, *args):
4221        """
4222        Get the user-specified metadata associated with a given key.
4223
4224        std::string Xapian::Database::get_metadata(const std::string &key)
4225        const
4226
4227        User-specified metadata allows you to store arbitrary information in
4228        the form of (key,tag) pairs. See  WritableDatabase::set_metadata() for
4229        more information.
4230
4231        When invoked on a Xapian::Database object representing multiple
4232        databases, currently only the metadata for the first is considered but
4233        this behaviour may change in the future.
4234
4235        If there is no piece of metadata associated with the specified key, an
4236        empty string is returned (this applies even for backends which don't
4237        support metadata).
4238
4239        Empty keys are not valid, and specifying one will cause an exception.
4240
4241        Parameters:
4242        -----------
4243
4244        key:  The key of the metadata item to access.
4245
4246        The retrieved metadata item's value.
4247
4248        Parameters:
4249        -----------
4250
4251        Xapian::InvalidArgumentError:  will be thrown if the key supplied is
4252        empty.
4253        """
4254        return _xapian.Database_get_metadata(self, *args)
4255
4256    def _metadata_keys_begin(self, prefix=""):
4257        """
4258        An iterator which returns all user-specified metadata keys.
4259
4260        Xapian::TermIterator Xapian::Database::metadata_keys_begin(const
4261        std::string &prefix=std::string()) const
4262
4263        When invoked on a Xapian::Database object representing multiple
4264        databases, currently only the metadata for the first is considered but
4265        this behaviour may change in the future.
4266
4267        If the backend doesn't support metadata, then this method returns an
4268        iterator which compares equal to that returned by metadata_keys_end().
4269
4270        Parameters:
4271        -----------
4272
4273        prefix:  If non-empty, only keys with this prefix are returned.
4274
4275        Parameters:
4276        -----------
4277
4278        Xapian::UnimplementedError:  will be thrown if the backend implements
4279        user-specified metadata, but doesn't implement iterating its keys
4280        (currently this happens for the InMemory backend).
4281        """
4282        return _xapian.Database__metadata_keys_begin(self, prefix)
4283
4284    def _metadata_keys_end(self, prefix=""):
4285        """
4286        Corresponding end iterator to metadata_keys_begin().
4287
4288        Xapian::TermIterator Xapian::Database::metadata_keys_end(const
4289        std::string &=std::string()) const
4290        """
4291        return _xapian.Database__metadata_keys_end(self, prefix)
4292
4293    def get_uuid(self):
4294        """
4295        Get a UUID for the database.
4296
4297        std::string Xapian::Database::get_uuid() const
4298
4299        The UUID will persist for the lifetime of the database.
4300
4301        Replicas (eg, made with the replication protocol, or by copying all
4302        the database files) will have the same UUID. However, copies (made
4303        with copydatabase, or xapian-compact) will have different UUIDs.
4304
4305        If the backend does not support UUIDs or this database has no
4306        subdatabases, the UUID will be empty.
4307
4308        If this database has multiple sub-databases, the UUID string will
4309        contain the UUIDs of all the sub-databases.
4310        """
4311        return _xapian.Database_get_uuid(self)
4312
4313    def has_positions(self):
4314        """
4315        Does this database have any positional information?
4316
4317        bool Xapian::Database::has_positions() const
4318        """
4319        return _xapian.Database_has_positions(self)
4320
4321Database.add_database = new_instancemethod(_xapian.Database_add_database,None,Database)
4322Database.reopen = new_instancemethod(_xapian.Database_reopen,None,Database)
4323Database.close = new_instancemethod(_xapian.Database_close,None,Database)
4324Database.__str__ = new_instancemethod(_xapian.Database___str__,None,Database)
4325Database.postlist_begin = new_instancemethod(_xapian.Database_postlist_begin,None,Database)
4326Database.postlist_end = new_instancemethod(_xapian.Database_postlist_end,None,Database)
4327Database.termlist_begin = new_instancemethod(_xapian.Database_termlist_begin,None,Database)
4328Database.termlist_end = new_instancemethod(_xapian.Database_termlist_end,None,Database)
4329Database.positionlist_begin = new_instancemethod(_xapian.Database_positionlist_begin,None,Database)
4330Database.positionlist_end = new_instancemethod(_xapian.Database_positionlist_end,None,Database)
4331Database.allterms_begin = new_instancemethod(_xapian.Database_allterms_begin,None,Database)
4332Database.allterms_end = new_instancemethod(_xapian.Database_allterms_end,None,Database)
4333Database.get_doccount = new_instancemethod(_xapian.Database_get_doccount,None,Database)
4334Database.get_lastdocid = new_instancemethod(_xapian.Database_get_lastdocid,None,Database)
4335Database.get_avlength = new_instancemethod(_xapian.Database_get_avlength,None,Database)
4336Database.get_termfreq = new_instancemethod(_xapian.Database_get_termfreq,None,Database)
4337Database.term_exists = new_instancemethod(_xapian.Database_term_exists,None,Database)
4338Database.get_collection_freq = new_instancemethod(_xapian.Database_get_collection_freq,None,Database)
4339Database.get_value_freq = new_instancemethod(_xapian.Database_get_value_freq,None,Database)
4340Database.get_value_lower_bound = new_instancemethod(_xapian.Database_get_value_lower_bound,None,Database)
4341Database.get_value_upper_bound = new_instancemethod(_xapian.Database_get_value_upper_bound,None,Database)
4342Database.get_doclength_lower_bound = new_instancemethod(_xapian.Database_get_doclength_lower_bound,None,Database)
4343Database.get_doclength_upper_bound = new_instancemethod(_xapian.Database_get_doclength_upper_bound,None,Database)
4344Database.get_wdf_upper_bound = new_instancemethod(_xapian.Database_get_wdf_upper_bound,None,Database)
4345Database.valuestream_begin = new_instancemethod(_xapian.Database_valuestream_begin,None,Database)
4346Database.valuestream_end = new_instancemethod(_xapian.Database_valuestream_end,None,Database)
4347Database.get_doclength = new_instancemethod(_xapian.Database_get_doclength,None,Database)
4348Database.keep_alive = new_instancemethod(_xapian.Database_keep_alive,None,Database)
4349Database.get_document = new_instancemethod(_xapian.Database_get_document,None,Database)
4350Database.get_spelling_suggestion = new_instancemethod(_xapian.Database_get_spelling_suggestion,None,Database)
4351Database.spellings_begin = new_instancemethod(_xapian.Database_spellings_begin,None,Database)
4352Database.spellings_end = new_instancemethod(_xapian.Database_spellings_end,None,Database)
4353Database.synonyms_begin = new_instancemethod(_xapian.Database_synonyms_begin,None,Database)
4354Database.synonyms_end = new_instancemethod(_xapian.Database_synonyms_end,None,Database)
4355Database.synonym_keys_begin = new_instancemethod(_xapian.Database_synonym_keys_begin,None,Database)
4356Database.synonym_keys_end = new_instancemethod(_xapian.Database_synonym_keys_end,None,Database)
4357Database.get_metadata = new_instancemethod(_xapian.Database_get_metadata,None,Database)
4358Database._metadata_keys_begin = new_instancemethod(_xapian.Database__metadata_keys_begin,None,Database)
4359Database._metadata_keys_end = new_instancemethod(_xapian.Database__metadata_keys_end,None,Database)
4360Database.get_uuid = new_instancemethod(_xapian.Database_get_uuid,None,Database)
4361Database.has_positions = new_instancemethod(_xapian.Database_has_positions,None,Database)
4362Database_swigregister = _xapian.Database_swigregister
4363Database_swigregister(Database)
4364
4365class WritableDatabase(Database):
4366    """
4367    This class provides read/write access to a database.
4368    """
4369    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
4370    __repr__ = _swig_repr
4371    __swig_destroy__ = _xapian.delete_WritableDatabase
4372    def __init__(self, *args):
4373        """
4374        Copying is allowed.
4375
4376        Xapian::WritableDatabase::WritableDatabase(const WritableDatabase
4377        &other)
4378
4379        The internals are reference counted, so copying is cheap.
4380
4381        Parameters:
4382        -----------
4383
4384        other:  The object to copy.
4385        """
4386        _xapian.WritableDatabase_swiginit(self,_xapian.new_WritableDatabase(*args))
4387    def commit(self):
4388        """
4389        Commit any pending modifications made to the database.
4390
4391        void Xapian::WritableDatabase::commit()
4392
4393        For efficiency reasons, when performing multiple updates to a database
4394        it is best (indeed, almost essential) to make as many modifications as
4395        memory will permit in a single pass through the database. To ensure
4396        this, Xapian batches up modifications.
4397
4398        This method may be called at any time to commit any pending
4399        modifications to the database.
4400
4401        If any of the modifications fail, an exception will be thrown and the
4402        database will be left in a state in which each separate addition,
4403        replacement or deletion operation has either been fully performed or
4404        not performed at all: it is then up to the application to work out
4405        which operations need to be repeated.
4406
4407        It's not valid to call commit() within a transaction.
4408
4409        Beware of calling commit() too frequently: this will make indexing
4410        take much longer.
4411
4412        Note that commit() need not be called explicitly: it will be called
4413        automatically when the database is closed, or when a sufficient number
4414        of modifications have been made. By default, this is every 10000
4415        documents added, deleted, or modified. This value is rather
4416        conservative, and if you have a machine with plenty of memory, you can
4417        improve indexing throughput dramatically by setting
4418        XAPIAN_FLUSH_THRESHOLD in the environment to a larger value.
4419
4420        This method was new in Xapian 1.1.0 - in earlier versions it was
4421        called flush().
4422
4423        Parameters:
4424        -----------
4425
4426        Xapian::DatabaseError:  will be thrown if a problem occurs while
4427        modifying the database.
4428
4429        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
4430        corrupt state.
4431        """
4432        return _xapian.WritableDatabase_commit(self)
4433
4434    def flush(self):
4435        """
4436        Pre-1.1.0 name for commit().
4437
4438        void Xapian::WritableDatabase::flush()
4439
4440        Use commit() instead in new code. This alias may be deprecated in the
4441        future.
4442        """
4443        return _xapian.WritableDatabase_flush(self)
4444
4445    def begin_transaction(self, flushed=True):
4446        """
4447        Begin a transaction.
4448
4449        void Xapian::WritableDatabase::begin_transaction(bool flushed=true)
4450
4451        In Xapian a transaction is a group of modifications to the database
4452        which are linked such that either all will be applied simultaneously
4453        or none will be applied at all. Even in the case of a power failure,
4454        this characteristic should be preserved (as long as the filesystem
4455        isn't corrupted, etc).
4456
4457        A transaction is started with begin_transaction() and can either be
4458        committed by calling commit_transaction() or aborted by calling
4459        cancel_transaction().
4460
4461        By default, a transaction implicitly calls commit() before and after
4462        so that the modifications stand and fall without affecting
4463        modifications before or after.
4464
4465        The downside of these implicit calls to commit() is that small
4466        transactions can harm indexing performance in the same way that
4467        explicitly calling commit() frequently can.
4468
4469        If you're applying atomic groups of changes and only wish to ensure
4470        that each group is either applied or not applied, then you can prevent
4471        the automatic commit() before and after the transaction by starting
4472        the transaction with begin_transaction(false). However, if
4473        cancel_transaction is called (or if commit_transaction isn't called
4474        before the WritableDatabase object is destroyed) then any changes
4475        which were pending before the transaction began will also be
4476        discarded.
4477
4478        Transactions aren't currently supported by the InMemory backend.
4479
4480        Parameters:
4481        -----------
4482
4483        flushed:  Is this a flushed transaction? By default transactions are
4484        "flushed", which means that committing a transaction will ensure
4485        those changes are permanently written to the database. By contrast,
4486        unflushed transactions only ensure that changes within the transaction
4487        are either all applied or all aren't.
4488
4489        Parameters:
4490        -----------
4491
4492        Xapian::UnimplementedError:  will be thrown if transactions are not
4493        available for this database type.
4494
4495        Xapian::InvalidOperationError:  will be thrown if this is called at an
4496        invalid time, such as when a transaction is already in progress.
4497        """
4498        return _xapian.WritableDatabase_begin_transaction(self, flushed)
4499
4500    def commit_transaction(self):
4501        """
4502        Complete the transaction currently in progress.
4503
4504        void Xapian::WritableDatabase::commit_transaction()
4505
4506        If this method completes successfully and this is a flushed
4507        transaction, all the database modifications made during the
4508        transaction will have been committed to the database.
4509
4510        If an error occurs, an exception will be thrown, and none of the
4511        modifications made to the database during the transaction will have
4512        been applied to the database.
4513
4514        In all cases the transaction will no longer be in progress.
4515
4516        Parameters:
4517        -----------
4518
4519        Xapian::DatabaseError:  will be thrown if a problem occurs while
4520        modifying the database.
4521
4522        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
4523        corrupt state.
4524
4525        Xapian::InvalidOperationError:  will be thrown if a transaction is not
4526        currently in progress.
4527
4528        Xapian::UnimplementedError:  will be thrown if transactions are not
4529        available for this database type.
4530        """
4531        return _xapian.WritableDatabase_commit_transaction(self)
4532
4533    def cancel_transaction(self):
4534        """
4535        Abort the transaction currently in progress, discarding the pending
4536        modifications made to the database.
4537
4538        void Xapian::WritableDatabase::cancel_transaction()
4539
4540        If an error occurs in this method, an exception will be thrown, but
4541        the transaction will be cancelled anyway.
4542
4543        Parameters:
4544        -----------
4545
4546        Xapian::DatabaseError:  will be thrown if a problem occurs while
4547        modifying the database.
4548
4549        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
4550        corrupt state.
4551
4552        Xapian::InvalidOperationError:  will be thrown if a transaction is not
4553        currently in progress.
4554
4555        Xapian::UnimplementedError:  will be thrown if transactions are not
4556        available for this database type.
4557        """
4558        return _xapian.WritableDatabase_cancel_transaction(self)
4559
4560    def add_document(self, *args):
4561        """
4562        Add a new document to the database.
4563
4564        Xapian::docid Xapian::WritableDatabase::add_document(const
4565        Xapian::Document &document)
4566
4567        This method adds the specified document to the database, returning a
4568        newly allocated document ID. Automatically allocated document IDs come
4569        from a per-database monotonically increasing counter, so IDs from
4570        deleted documents won't be reused.
4571
4572        If you want to specify the document ID to be used, you should call
4573        replace_document() instead.
4574
4575        Note that changes to the database won't be immediately committed to
4576        disk; see commit() for more details.
4577
4578        As with all database modification operations, the effect is atomic:
4579        the document will either be fully added, or the document fails to be
4580        added and an exception is thrown (possibly at a later time when
4581        commit() is called or the database is closed).
4582
4583        Parameters:
4584        -----------
4585
4586        document:  The new document to be added.
4587
4588        The document ID of the newly added document.
4589
4590        Parameters:
4591        -----------
4592
4593        Xapian::DatabaseError:  will be thrown if a problem occurs while
4594        writing to the database.
4595
4596        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
4597        corrupt state.
4598        """
4599        return _xapian.WritableDatabase_add_document(self, *args)
4600
4601    def delete_document(self, *args):
4602        """
4603        Delete any documents indexed by a term from the database.
4604
4605        void Xapian::WritableDatabase::delete_document(const std::string
4606        &unique_term)
4607
4608        This method removes any documents indexed by the specified term from
4609        the database.
4610
4611        A major use is for convenience when UIDs from another system are
4612        mapped to terms in Xapian, although this method has other uses (for
4613        example, you could add a "deletion date" term to documents at index
4614        time and use this method to delete all documents due for deletion on a
4615        particular date).
4616
4617        Parameters:
4618        -----------
4619
4620        unique_term:  The term to remove references to.
4621
4622        Parameters:
4623        -----------
4624
4625        Xapian::DatabaseError:  will be thrown if a problem occurs while
4626        writing to the database.
4627
4628        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
4629        corrupt state.
4630        """
4631        return _xapian.WritableDatabase_delete_document(self, *args)
4632
4633    def replace_document(self, *args):
4634        """
4635        Replace any documents matching a term.
4636
4637        Xapian::docid Xapian::WritableDatabase::replace_document(const
4638        std::string &unique_term, const Xapian::Document &document)
4639
4640        This method replaces any documents indexed by the specified term with
4641        the specified document. If any documents are indexed by the term, the
4642        lowest document ID will be used for the document, otherwise a new
4643        document ID will be generated as for add_document.
4644
4645        One common use is to allow UIDs from another system to easily be
4646        mapped to terms in Xapian. Note that this method doesn't automatically
4647        add unique_term as a term, so you'll need to call
4648        document.add_term(unique_term) first when using replace_document() in
4649        this way.
4650
4651        Note that changes to the database won't be immediately committed to
4652        disk; see commit() for more details.
4653
4654        As with all database modification operations, the effect is atomic:
4655        the document(s) will either be fully replaced, or the document(s) fail
4656        to be replaced and an exception is thrown (possibly at a later time
4657        when commit() is called or the database is closed).
4658
4659        Parameters:
4660        -----------
4661
4662        unique_term:  The "unique" term.
4663
4664        document:  The new document.
4665
4666        The document ID that document was given.
4667
4668        Parameters:
4669        -----------
4670
4671        Xapian::DatabaseError:  will be thrown if a problem occurs while
4672        writing to the database.
4673
4674        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
4675        corrupt state.
4676        """
4677        return _xapian.WritableDatabase_replace_document(self, *args)
4678
4679    def add_spelling(self, *args):
4680        """
4681        Add a word to the spelling dictionary.
4682
4683        void Xapian::WritableDatabase::add_spelling(const std::string &word,
4684        Xapian::termcount freqinc=1) const
4685
4686        If the word is already present, its frequency is increased.
4687
4688        Parameters:
4689        -----------
4690
4691        word:  The word to add.
4692
4693        freqinc:  How much to increase its frequency by (default 1).
4694        """
4695        return _xapian.WritableDatabase_add_spelling(self, *args)
4696
4697    def remove_spelling(self, *args):
4698        """
4699        Remove a word from the spelling dictionary.
4700
4701        void Xapian::WritableDatabase::remove_spelling(const std::string
4702        &word, Xapian::termcount freqdec=1) const
4703
4704        The word's frequency is decreased, and if would become zero or less
4705        then the word is removed completely.
4706
4707        Parameters:
4708        -----------
4709
4710        word:  The word to remove.
4711
4712        freqdec:  How much to decrease its frequency by (default 1).
4713        """
4714        return _xapian.WritableDatabase_remove_spelling(self, *args)
4715
4716    def add_synonym(self, *args):
4717        """
4718        Add a synonym for a term.
4719
4720        void Xapian::WritableDatabase::add_synonym(const std::string &term,
4721        const std::string &synonym) const
4722
4723        Parameters:
4724        -----------
4725
4726        term:  The term to add a synonym for.
4727
4728        synonym:  The synonym to add. If this is already a synonym for term,
4729        then no action is taken.
4730        """
4731        return _xapian.WritableDatabase_add_synonym(self, *args)
4732
4733    def remove_synonym(self, *args):
4734        """
4735        Remove a synonym for a term.
4736
4737        void Xapian::WritableDatabase::remove_synonym(const std::string &term,
4738        const std::string &synonym) const
4739
4740        Parameters:
4741        -----------
4742
4743        term:  The term to remove a synonym for.
4744
4745        synonym:  The synonym to remove. If this isn't currently a synonym for
4746        term, then no action is taken.
4747        """
4748        return _xapian.WritableDatabase_remove_synonym(self, *args)
4749
4750    def clear_synonyms(self, *args):
4751        """
4752        Remove all synonyms for a term.
4753
4754        void Xapian::WritableDatabase::clear_synonyms(const std::string &term)
4755        const
4756
4757        Parameters:
4758        -----------
4759
4760        term:  The term to remove all synonyms for. If the term has no
4761        synonyms, no action is taken.
4762        """
4763        return _xapian.WritableDatabase_clear_synonyms(self, *args)
4764
4765    def set_metadata(self, *args):
4766        """
4767        Set the user-specified metadata associated with a given key.
4768
4769        void Xapian::WritableDatabase::set_metadata(const std::string &key,
4770        const std::string &value)
4771
4772        This method sets the metadata value associated with a given key. If
4773        there is already a metadata value stored in the database with the same
4774        key, the old value is replaced. If you want to delete an existing item
4775        of metadata, just set its value to the empty string.
4776
4777        User-specified metadata allows you to store arbitrary information in
4778        the form of (key,tag) pairs.
4779
4780        There's no hard limit on the number of metadata items, or the size of
4781        the metadata values. Metadata keys have a limited length, which
4782        depends on the backend. We recommend limiting them to 200 bytes. Empty
4783        keys are not valid, and specifying one will cause an exception.
4784
4785        Metadata modifications are committed to disk in the same way as
4786        modifications to the documents in the database are: i.e.,
4787        modifications are atomic, and won't be committed to disk immediately
4788        (see commit() for more details). This allows metadata to be used to
4789        link databases with versioned external resources by storing the
4790        appropriate version number in a metadata item.
4791
4792        You can also use the metadata to store arbitrary extra information
4793        associated with terms, documents, or postings by encoding the termname
4794        and/or document id into the metadata key.
4795
4796        Parameters:
4797        -----------
4798
4799        key:  The key of the metadata item to set.
4800
4801        value:  The value of the metadata item to set.
4802
4803        Parameters:
4804        -----------
4805
4806        Xapian::DatabaseError:  will be thrown if a problem occurs while
4807        writing to the database.
4808
4809        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
4810        corrupt state.
4811
4812        Xapian::InvalidArgumentError:  will be thrown if the key supplied is
4813        empty.
4814
4815        Xapian::UnimplementedError:  will be thrown if the database backend in
4816        use doesn't support user- specified metadata.
4817        """
4818        return _xapian.WritableDatabase_set_metadata(self, *args)
4819
4820    def __str__(self):
4821        """
4822        Return a string describing this object.
4823
4824        std::string Xapian::WritableDatabase::get_description() const
4825        """
4826        return _xapian.WritableDatabase___str__(self)
4827
4828WritableDatabase.commit = new_instancemethod(_xapian.WritableDatabase_commit,None,WritableDatabase)
4829WritableDatabase.flush = new_instancemethod(_xapian.WritableDatabase_flush,None,WritableDatabase)
4830WritableDatabase.begin_transaction = new_instancemethod(_xapian.WritableDatabase_begin_transaction,None,WritableDatabase)
4831WritableDatabase.commit_transaction = new_instancemethod(_xapian.WritableDatabase_commit_transaction,None,WritableDatabase)
4832WritableDatabase.cancel_transaction = new_instancemethod(_xapian.WritableDatabase_cancel_transaction,None,WritableDatabase)
4833WritableDatabase.add_document = new_instancemethod(_xapian.WritableDatabase_add_document,None,WritableDatabase)
4834WritableDatabase.delete_document = new_instancemethod(_xapian.WritableDatabase_delete_document,None,WritableDatabase)
4835WritableDatabase.replace_document = new_instancemethod(_xapian.WritableDatabase_replace_document,None,WritableDatabase)
4836WritableDatabase.add_spelling = new_instancemethod(_xapian.WritableDatabase_add_spelling,None,WritableDatabase)
4837WritableDatabase.remove_spelling = new_instancemethod(_xapian.WritableDatabase_remove_spelling,None,WritableDatabase)
4838WritableDatabase.add_synonym = new_instancemethod(_xapian.WritableDatabase_add_synonym,None,WritableDatabase)
4839WritableDatabase.remove_synonym = new_instancemethod(_xapian.WritableDatabase_remove_synonym,None,WritableDatabase)
4840WritableDatabase.clear_synonyms = new_instancemethod(_xapian.WritableDatabase_clear_synonyms,None,WritableDatabase)
4841WritableDatabase.set_metadata = new_instancemethod(_xapian.WritableDatabase_set_metadata,None,WritableDatabase)
4842WritableDatabase.__str__ = new_instancemethod(_xapian.WritableDatabase___str__,None,WritableDatabase)
4843WritableDatabase_swigregister = _xapian.WritableDatabase_swigregister
4844WritableDatabase_swigregister(WritableDatabase)
4845
4846DB_CREATE_OR_OPEN = _xapian.DB_CREATE_OR_OPEN
4847DB_CREATE = _xapian.DB_CREATE
4848DB_CREATE_OR_OVERWRITE = _xapian.DB_CREATE_OR_OVERWRITE
4849DB_OPEN = _xapian.DB_OPEN
4850
4851def open_stub(*args):
4852  """
4853    Construct a WritableDatabase object for a stub database file.
4854
4855    WritableDatabase Xapian::Auto::open_stub(const std::string &file, int
4856    action)
4857
4858    The stub database file must contain serialised parameters for exactly
4859    one database.
4860
4861    Parameters:
4862    -----------
4863
4864    file:  pathname of the stub database file.
4865
4866    action:  determines handling of existing/non-existing database:
4867    Xapian::DB_CREATE fail if database already exist, otherwise create new
4868    database.
4869
4870    Xapian::DB_CREATE_OR_OPEN open existing database, or create new
4871    database if none exists.
4872
4873    Xapian::DB_CREATE_OR_OVERWRITE overwrite existing database, or create
4874    new database if none exists.
4875
4876    Xapian::DB_OPEN open existing database, failing if none exists.
4877    """
4878  return _xapian.open_stub(*args)
4879
4880def brass_open(*args):
4881  """
4882    Construct a Database object for update access to a Brass database.
4883
4884    WritableDatabase Xapian::Brass::open(const std::string &dir, int
4885    action, int block_size=8192)
4886
4887    Parameters:
4888    -----------
4889
4890    dir:  pathname of the directory containing the database.
4891
4892    action:  determines handling of existing/non-existing database:
4893    Xapian::DB_CREATE fail if database already exist, otherwise create new
4894    database.
4895
4896    Xapian::DB_CREATE_OR_OPEN open existing database, or create new
4897    database if none exists.
4898
4899    Xapian::DB_CREATE_OR_OVERWRITE overwrite existing database, or create
4900    new database if none exists.
4901
4902    Xapian::DB_OPEN open existing database, failing if none exists.
4903
4904    block_size:  the Btree blocksize to use (in bytes), which must be a
4905    power of two between 2048 and 65536 (inclusive). The default (also
4906    used if an invalid value if passed) is 8192 bytes. This parameter is
4907    ignored when opening an existing database.
4908    """
4909  return _xapian.brass_open(*args)
4910
4911def chert_open(*args):
4912  """
4913    Construct a Database object for update access to a Chert database.
4914
4915    WritableDatabase Xapian::Chert::open(const std::string &dir, int
4916    action, int block_size=8192)
4917
4918    Parameters:
4919    -----------
4920
4921    dir:  pathname of the directory containing the database.
4922
4923    action:  determines handling of existing/non-existing database:
4924    Xapian::DB_CREATE fail if database already exist, otherwise create new
4925    database.
4926
4927    Xapian::DB_CREATE_OR_OPEN open existing database, or create new
4928    database if none exists.
4929
4930    Xapian::DB_CREATE_OR_OVERWRITE overwrite existing database, or create
4931    new database if none exists.
4932
4933    Xapian::DB_OPEN open existing database, failing if none exists.
4934
4935    block_size:  the Btree blocksize to use (in bytes), which must be a
4936    power of two between 2048 and 65536 (inclusive). The default (also
4937    used if an invalid value if passed) is 8192 bytes. This parameter is
4938    ignored when opening an existing database.
4939    """
4940  return _xapian.chert_open(*args)
4941
4942def flint_open(*args):
4943  """
4944    Construct a Database object for update access to a Flint database.
4945
4946    WritableDatabase Xapian::Flint::open(const std::string &dir, int
4947    action, int block_size=8192)
4948
4949    Parameters:
4950    -----------
4951
4952    dir:  pathname of the directory containing the database.
4953
4954    action:  determines handling of existing/non-existing database:
4955    Xapian::DB_CREATE fail if database already exist, otherwise create new
4956    database.
4957
4958    Xapian::DB_CREATE_OR_OPEN open existing database, or create new
4959    database if none exists.
4960
4961    Xapian::DB_CREATE_OR_OVERWRITE overwrite existing database, or create
4962    new database if none exists.
4963
4964    Xapian::DB_OPEN open existing database, failing if none exists.
4965
4966    block_size:  the Btree blocksize to use (in bytes), which must be a
4967    power of two between 2048 and 65536 (inclusive). The default (also
4968    used if an invalid value if passed) is 8192 bytes. This parameter is
4969    ignored when opening an existing database.
4970    """
4971  return _xapian.flint_open(*args)
4972
4973def inmemory_open():
4974  """
4975    Construct a WritableDatabase object for a new, empty InMemory
4976    database.
4977
4978    WritableDatabase Xapian::InMemory::open()
4979
4980    Only a writable InMemory database can be created, since a read-only
4981    one would always remain empty.
4982    """
4983  return _xapian.inmemory_open()
4984
4985def remote_open(*args):
4986  """
4987    Construct a Database object for read-only access to a remote database
4988    accessed via a program.
4989
4990    Database Xapian::Remote::open(const std::string &program, const
4991    std::string &args, Xapian::timeout timeout=10000)
4992
4993    Access to the remote database is done by running an external program
4994    and communicating with it on stdin/stdout.
4995
4996    Parameters:
4997    -----------
4998
4999    program:  the external program to run.
5000
5001    args:  space-separated list of arguments to pass to program.
5002
5003    timeout:  timeout in milliseconds. If this timeout is exceeded for any
5004    individual operation on the remote database then
5005    Xapian::NetworkTimeoutError is thrown. A timeout of 0 means don't
5006    timeout. (Default is 10000ms, which is 10 seconds).
5007    """
5008  return _xapian.remote_open(*args)
5009
5010def remote_open_writable(*args):
5011  """
5012    Construct a WritableDatabase object for update access to a remote
5013    database accessed via a program.
5014
5015    WritableDatabase Xapian::Remote::open_writable(const std::string
5016    &program, const std::string &args, Xapian::timeout timeout=0)
5017
5018    Access to the remote database is done by running an external program
5019    and communicating with it on stdin/stdout.
5020
5021    Parameters:
5022    -----------
5023
5024    program:  the external program to run.
5025
5026    args:  space-separated list of arguments to pass to program.
5027
5028    timeout:  timeout in milliseconds. If this timeout is exceeded for any
5029    individual operation on the remote database then
5030    Xapian::NetworkTimeoutError is thrown. (Default is 0, which means
5031    don't timeout).
5032    """
5033  return _xapian.remote_open_writable(*args)
5034class Query(object):
5035    """
5036    Class representing a query.
5037
5038    Queries are represented as a tree of objects.
5039    """
5040    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5041    __repr__ = _swig_repr
5042    OP_AND = _xapian.Query_OP_AND
5043    OP_OR = _xapian.Query_OP_OR
5044    OP_AND_NOT = _xapian.Query_OP_AND_NOT
5045    OP_XOR = _xapian.Query_OP_XOR
5046    OP_AND_MAYBE = _xapian.Query_OP_AND_MAYBE
5047    OP_FILTER = _xapian.Query_OP_FILTER
5048    OP_NEAR = _xapian.Query_OP_NEAR
5049    OP_PHRASE = _xapian.Query_OP_PHRASE
5050    OP_VALUE_RANGE = _xapian.Query_OP_VALUE_RANGE
5051    OP_SCALE_WEIGHT = _xapian.Query_OP_SCALE_WEIGHT
5052    OP_ELITE_SET = _xapian.Query_OP_ELITE_SET
5053    OP_VALUE_GE = _xapian.Query_OP_VALUE_GE
5054    OP_VALUE_LE = _xapian.Query_OP_VALUE_LE
5055    OP_SYNONYM = _xapian.Query_OP_SYNONYM
5056    __swig_destroy__ = _xapian.delete_Query
5057    def get_length(self):
5058        """
5059        Get the length of the query, used by some ranking formulae.
5060
5061        Xapian::termcount Xapian::Query::get_length() const
5062
5063        This value is calculated automatically - if you want to override it
5064        you can pass a different value to Enquire::set_query().
5065        """
5066        return _xapian.Query_get_length(self)
5067
5068    def get_terms_begin(self):
5069        """
5070        Return a Xapian::TermIterator returning all the terms in the query, in
5071        order of termpos.
5072
5073        TermIterator Xapian::Query::get_terms_begin() const
5074
5075        If multiple terms have the same term position, their order is
5076        unspecified. Duplicates (same term and termpos) will be removed.
5077        """
5078        return _xapian.Query_get_terms_begin(self)
5079
5080    def get_terms_end(self):
5081        """
5082        Return a Xapian::TermIterator to the end of the list of terms in the
5083        query.
5084
5085        TermIterator Xapian::Query::get_terms_end() const
5086        """
5087        return _xapian.Query_get_terms_end(self)
5088
5089    def empty(self):
5090        """
5091        Test if the query is empty (i.e.
5092
5093        bool Xapian::Query::empty() const
5094
5095        was constructed using the default ctor or with an empty iterator
5096        ctor).
5097        """
5098        return _xapian.Query_empty(self)
5099
5100    def serialise(self):
5101        """
5102        Serialise query into a string.
5103
5104        std::string Xapian::Query::serialise() const
5105
5106        The query representation may change between Xapian releases: even
5107        between minor versions. However, it is guaranteed not to change unless
5108        the remote database protocol has also changed between releases.
5109        """
5110        return _xapian.Query_serialise(self)
5111
5112    unserialise = staticmethod(_xapian.Query_unserialise)
5113    def __str__(self):
5114        """
5115        Return a string describing this object.
5116
5117        std::string Xapian::Query::get_description() const
5118        """
5119        return _xapian.Query___str__(self)
5120
5121    def __init__(self, *args):
5122        """
5123        Construct an external source query.
5124
5125        Xapian::Query::Query(Xapian::PostingSource *external_source)
5126
5127        An attempt to clone the posting source will be made immediately, so if
5128        the posting source supports clone(), the source supplied may be safely
5129        deallocated after this call. If the source does not support clone(),
5130        the caller must ensure that the posting source remains valid until the
5131        Query is deallocated.
5132
5133        Parameters:
5134        -----------
5135
5136        external_source:  The source to use in the query.
5137        """
5138        _xapian.Query_swiginit(self,_xapian.new_Query(*args))
5139Query.get_length = new_instancemethod(_xapian.Query_get_length,None,Query)
5140Query.get_terms_begin = new_instancemethod(_xapian.Query_get_terms_begin,None,Query)
5141Query.get_terms_end = new_instancemethod(_xapian.Query_get_terms_end,None,Query)
5142Query.empty = new_instancemethod(_xapian.Query_empty,None,Query)
5143Query.serialise = new_instancemethod(_xapian.Query_serialise,None,Query)
5144Query.__str__ = new_instancemethod(_xapian.Query___str__,None,Query)
5145Query_swigregister = _xapian.Query_swigregister
5146Query_swigregister(Query)
5147
5148def Query_unserialise(*args):
5149  return _xapian.Query_unserialise(*args)
5150Query_unserialise = _xapian.Query_unserialise
5151
5152class Stopper(object):
5153    """
5154    Base class for stop-word decision functor.
5155    """
5156    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5157    __repr__ = _swig_repr
5158    __swig_destroy__ = _xapian.delete_Stopper
5159    def __str__(self):
5160        """
5161        Return a string describing this object.
5162
5163        virtual std::string Xapian::Stopper::get_description() const
5164        """
5165        return _xapian.Stopper___str__(self)
5166
5167    def __init__(self):
5168        if self.__class__ == Stopper:
5169            _self = None
5170        else:
5171            _self = self
5172        _xapian.Stopper_swiginit(self,_xapian.new_Stopper(_self, ))
5173    def __disown__(self):
5174        self.this.disown()
5175        _xapian.disown_Stopper(self)
5176        return weakref_proxy(self)
5177Stopper.__call__ = new_instancemethod(_xapian.Stopper___call__,None,Stopper)
5178Stopper.__str__ = new_instancemethod(_xapian.Stopper___str__,None,Stopper)
5179Stopper_swigregister = _xapian.Stopper_swigregister
5180Stopper_swigregister(Stopper)
5181
5182class SimpleStopper(Stopper):
5183    """
5184    Simple implementation of Stopper class - this will suit most users.
5185    """
5186    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5187    __repr__ = _swig_repr
5188    def __init__(self):
5189        """
5190        Initialise from a pair of iterators.
5191
5192        Xapian::SimpleStopper::SimpleStopper(Iterator begin, Iterator end)
5193
5194        Xapian includes stop list files for many languages. You can initialise
5195        from a file like that:
5196        """
5197        _xapian.SimpleStopper_swiginit(self,_xapian.new_SimpleStopper())
5198    def add(self, *args):
5199        """
5200        Add a single stop word.
5201
5202        void Xapian::SimpleStopper::add(const std::string &word)
5203        """
5204        return _xapian.SimpleStopper_add(self, *args)
5205
5206    __swig_destroy__ = _xapian.delete_SimpleStopper
5207SimpleStopper.add = new_instancemethod(_xapian.SimpleStopper_add,None,SimpleStopper)
5208SimpleStopper_swigregister = _xapian.SimpleStopper_swigregister
5209SimpleStopper_swigregister(SimpleStopper)
5210
5211class ValueRangeProcessor(object):
5212    """
5213    Base class for value range processors.
5214    """
5215    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5216    __repr__ = _swig_repr
5217    __swig_destroy__ = _xapian.delete_ValueRangeProcessor
5218    def __init__(self):
5219        if self.__class__ == ValueRangeProcessor:
5220            _self = None
5221        else:
5222            _self = self
5223        _xapian.ValueRangeProcessor_swiginit(self,_xapian.new_ValueRangeProcessor(_self, ))
5224    def __disown__(self):
5225        self.this.disown()
5226        _xapian.disown_ValueRangeProcessor(self)
5227        return weakref_proxy(self)
5228ValueRangeProcessor.__call__ = new_instancemethod(_xapian.ValueRangeProcessor___call__,None,ValueRangeProcessor)
5229ValueRangeProcessor_swigregister = _xapian.ValueRangeProcessor_swigregister
5230ValueRangeProcessor_swigregister(ValueRangeProcessor)
5231
5232class StringValueRangeProcessor(ValueRangeProcessor):
5233    """
5234    Handle a string range.
5235
5236    The end points can be any strings.
5237    """
5238    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5239    __repr__ = _swig_repr
5240    def __init__(self, *args):
5241        """
5242        Constructor.
5243
5244        Xapian::StringValueRangeProcessor::StringValueRangeProcessor(Xapian::valueno
5245        slot_, const std::string &str_, bool prefix_=true)
5246
5247        Parameters:
5248        -----------
5249
5250        slot_:  The value number to return from operator().
5251
5252        str_:  A string to look for to recognise values as belonging to this
5253        range.
5254
5255        prefix_:  Flag specifying whether to check for str_ as a prefix or a
5256        suffix.
5257        """
5258        _xapian.StringValueRangeProcessor_swiginit(self,_xapian.new_StringValueRangeProcessor(*args))
5259    __swig_destroy__ = _xapian.delete_StringValueRangeProcessor
5260StringValueRangeProcessor_swigregister = _xapian.StringValueRangeProcessor_swigregister
5261StringValueRangeProcessor_swigregister(StringValueRangeProcessor)
5262
5263class DateValueRangeProcessor(StringValueRangeProcessor):
5264    """
5265    Handle a date range.
5266
5267    Begin and end must be dates in a recognised format.
5268    """
5269    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5270    __repr__ = _swig_repr
5271    def __init__(self, *args):
5272        """
5273        Constructor.
5274
5275        Xapian::DateValueRangeProcessor::DateValueRangeProcessor(Xapian::valueno
5276        slot_, const char *str_, bool prefix_=true, bool prefer_mdy_=false,
5277        int epoch_year_=1970)
5278
5279        This is like the previous version, but with const char * instead of
5280        std::string - we need this overload as otherwise
5281        DateValueRangeProcessor(1, "date:") quietly interprets the second
5282        argument as a boolean in preference to std::string. If you want to be
5283        compatible with 1.2.12 and earlier, then explicitly convert to
5284        std::string, i.e.: DateValueRangeProcessor(1, std::string("date:"))
5285
5286        Parameters:
5287        -----------
5288
5289        slot_:  The value number to return from operator().
5290
5291        str_:  A string to look for to recognise values as belonging to this
5292        date range.
5293
5294        prefix_:  Whether to look for the string at the start or end of the
5295        values. If true, the string is a prefix; if false, the string is a
5296        suffix (default: true).
5297
5298        prefer_mdy_:  Should ambiguous dates be interpreted as month/day/year
5299        rather than day/month/year? (default: false)
5300
5301        epoch_year_:  Year to use as the epoch for dates with 2 digit years
5302        (default: 1970, so 1/1/69 is 2069 while 1/1/70 is 1970).
5303
5304        The string supplied in str_ is used by operator() to decide whether
5305        the pair of strings supplied to it constitute a valid range. If
5306        prefix_ is true, the first value in a range must begin with str_ (and
5307        the second value may optionally begin with str_); if prefix_ is false,
5308        the second value in a range must end with str_ (and the first value
5309        may optionally end with str_).
5310
5311        If str_ is empty, the setting of prefix_ is irrelevant, and no special
5312        strings are required at the start or end of the strings defining the
5313        range.
5314
5315        The remainder of both strings defining the endpoints must be valid
5316        dates.
5317
5318        For example, if str_ is "created:" and prefix_ is true, and the
5319        range processor has been added to the queryparser, the queryparser
5320        will accept "created:1/1/2000..31/12/2001".
5321        """
5322        _xapian.DateValueRangeProcessor_swiginit(self,_xapian.new_DateValueRangeProcessor(*args))
5323    __swig_destroy__ = _xapian.delete_DateValueRangeProcessor
5324DateValueRangeProcessor_swigregister = _xapian.DateValueRangeProcessor_swigregister
5325DateValueRangeProcessor_swigregister(DateValueRangeProcessor)
5326
5327class NumberValueRangeProcessor(StringValueRangeProcessor):
5328    """
5329    Handle a number range.
5330
5331    This class must be used on values which have been encoded using
5332    Xapian::sortable_serialise() which turns numbers into strings which
5333    will sort in the same order as the numbers (the same values can be
5334    used to implement a numeric sort).
5335    """
5336    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5337    __repr__ = _swig_repr
5338    def __init__(self, *args):
5339        """
5340        Constructor.
5341
5342        Xapian::NumberValueRangeProcessor::NumberValueRangeProcessor(Xapian::valueno
5343        slot_, const std::string &str_, bool prefix_=true)
5344
5345        Parameters:
5346        -----------
5347
5348        slot_:  The value number to return from operator().
5349
5350        str_:  A string to look for to recognise values as belonging to this
5351        numeric range.
5352
5353        prefix_:  Whether to look for the string at the start or end of the
5354        values. If true, the string is a prefix; if false, the string is a
5355        suffix (default: true).
5356
5357        The string supplied in str_ is used by operator() to decide whether
5358        the pair of strings supplied to it constitute a valid range. If
5359        prefix_ is true, the first value in a range must begin with str_ (and
5360        the second value may optionally begin with str_); if prefix_ is false,
5361        the second value in a range must end with str_ (and the first value
5362        may optionally end with str_).
5363
5364        If str_ is empty, the setting of prefix_ is irrelevant, and no special
5365        strings are required at the start or end of the strings defining the
5366        range.
5367
5368        The remainder of both strings defining the endpoints must be valid
5369        floating point numbers. (FIXME: define format recognised).
5370
5371        For example, if str_ is "$" and prefix_ is true, and the range
5372        processor has been added to the queryparser, the queryparser will
5373        accept "$10..50" or "$10..$50", but not "10..50" or "10..$50"
5374        as valid ranges. If str_ is "kg" and prefix_ is false, the
5375        queryparser will accept "10..50kg" or "10kg..50kg", but not
5376        "10..50" or "10kg..50" as valid ranges.
5377        """
5378        _xapian.NumberValueRangeProcessor_swiginit(self,_xapian.new_NumberValueRangeProcessor(*args))
5379    __swig_destroy__ = _xapian.delete_NumberValueRangeProcessor
5380NumberValueRangeProcessor_swigregister = _xapian.NumberValueRangeProcessor_swigregister
5381NumberValueRangeProcessor_swigregister(NumberValueRangeProcessor)
5382
5383class QueryParser(object):
5384    """
5385    Build a Xapian::Query object from a user query string.
5386    """
5387    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5388    __repr__ = _swig_repr
5389    FLAG_BOOLEAN = _xapian.QueryParser_FLAG_BOOLEAN
5390    FLAG_PHRASE = _xapian.QueryParser_FLAG_PHRASE
5391    FLAG_LOVEHATE = _xapian.QueryParser_FLAG_LOVEHATE
5392    FLAG_BOOLEAN_ANY_CASE = _xapian.QueryParser_FLAG_BOOLEAN_ANY_CASE
5393    FLAG_WILDCARD = _xapian.QueryParser_FLAG_WILDCARD
5394    FLAG_PURE_NOT = _xapian.QueryParser_FLAG_PURE_NOT
5395    FLAG_PARTIAL = _xapian.QueryParser_FLAG_PARTIAL
5396    FLAG_SPELLING_CORRECTION = _xapian.QueryParser_FLAG_SPELLING_CORRECTION
5397    FLAG_SYNONYM = _xapian.QueryParser_FLAG_SYNONYM
5398    FLAG_AUTO_SYNONYMS = _xapian.QueryParser_FLAG_AUTO_SYNONYMS
5399    FLAG_AUTO_MULTIWORD_SYNONYMS = _xapian.QueryParser_FLAG_AUTO_MULTIWORD_SYNONYMS
5400    FLAG_CJK_NGRAM = _xapian.QueryParser_FLAG_CJK_NGRAM
5401    FLAG_DEFAULT = _xapian.QueryParser_FLAG_DEFAULT
5402    STEM_NONE = _xapian.QueryParser_STEM_NONE
5403    STEM_SOME = _xapian.QueryParser_STEM_SOME
5404    STEM_ALL = _xapian.QueryParser_STEM_ALL
5405    STEM_ALL_Z = _xapian.QueryParser_STEM_ALL_Z
5406    def __init__(self):
5407        """
5408        Default constructor.
5409
5410        Xapian::QueryParser::QueryParser()
5411        """
5412        _xapian.QueryParser_swiginit(self,_xapian.new_QueryParser())
5413    __swig_destroy__ = _xapian.delete_QueryParser
5414    def set_stemmer(self, *args):
5415        """
5416        Set the stemmer.
5417
5418        void Xapian::QueryParser::set_stemmer(const Xapian::Stem &stemmer)
5419
5420        This sets the stemming algorithm which will be used by the query
5421        parser. Note that the stemming algorithm will only be used according
5422        to the stemming strategy set by set_stemming_strategy(), which
5423        defaults to STEM_NONE. Therefore, to use a stemming algorithm, you
5424        will also need to call set_stemming_strategy() with a value other than
5425        STEM_NONE.
5426
5427        Parameters:
5428        -----------
5429
5430        stemmer:  The Xapian::Stem object to set.
5431        """
5432        return _xapian.QueryParser_set_stemmer(self, *args)
5433
5434    def set_stemming_strategy(self, *args):
5435        """
5436        Set the stemming strategy.
5437
5438        void Xapian::QueryParser::set_stemming_strategy(stem_strategy
5439        strategy)
5440
5441        This controls how the query parser will apply the stemming algorithm.
5442        Note that the stemming algorithm is only applied to words in
5443        probabilistic fields - boolean filter terms are never stemmed.
5444
5445        Parameters:
5446        -----------
5447
5448        strategy:  The strategy to use - possible values are: STEM_NONE: Don't
5449        perform any stemming. (default in Xapian <= 1.3.0)
5450
5451        STEM_SOME: Stem all terms except for those which start with a capital
5452        letter, or are followed by certain characters (currently: (/@<>=*[{"
5453        ), or are used with operators which need positional information.
5454        Stemmed terms are prefixed with 'Z'. (default in Xapian >= 1.3.1)
5455
5456        STEM_ALL: Stem all terms (note: no 'Z' prefix is added).
5457
5458        STEM_ALL_Z: Stem all terms (note: 'Z' prefix is added). (new in Xapian
5459        1.2.11 and 1.3.1)
5460        """
5461        return _xapian.QueryParser_set_stemming_strategy(self, *args)
5462
5463    def set_stopper(self, stop=None):
5464        """
5465        Set the stopper.
5466
5467        void Xapian::QueryParser::set_stopper(const Stopper *stop=NULL)
5468
5469        Parameters:
5470        -----------
5471
5472        stop:  The Stopper object to set (default NULL, which means no
5473        stopwords).
5474        """
5475        return _xapian.QueryParser_set_stopper(self, stop)
5476
5477    def set_default_op(self, *args):
5478        """
5479        Set the default operator.
5480
5481        void Xapian::QueryParser::set_default_op(Query::op default_op)
5482
5483        Parameters:
5484        -----------
5485
5486        default_op:  The operator to use to combine non-filter query items
5487        when no explicit operator is used.
5488
5489        The most useful values for this are OP_OR (the default) and OP_AND.
5490        OP_NEAR and OP_PHRASE can also be useful.
5491
5492        So for example, 'weather forecast' is parsed as if it were 'weather OR
5493        forecast' by default.
5494        """
5495        return _xapian.QueryParser_set_default_op(self, *args)
5496
5497    def get_default_op(self):
5498        """
5499        Get the current default operator.
5500
5501        Query::op Xapian::QueryParser::get_default_op() const
5502        """
5503        return _xapian.QueryParser_get_default_op(self)
5504
5505    def set_database(self, *args):
5506        """
5507        Specify the database being searched.
5508
5509        void Xapian::QueryParser::set_database(const Database &db)
5510
5511        Parameters:
5512        -----------
5513
5514        db:  The database to use for wildcard expansion (FLAG_WILDCARD and
5515        FLAG_PARTIAL), spelling correction (FLAG_SPELLING_CORRECTION), and
5516        synonyms (FLAG_SYNONYM, FLAG_AUTO_SYNONYMS, and
5517        FLAG_AUTO_MULTIWORD_SYNONYMS).
5518        """
5519        return _xapian.QueryParser_set_database(self, *args)
5520
5521    def set_max_wildcard_expansion(self, *args):
5522        """
5523        Specify the maximum expansion of a wildcard term.
5524
5525        void Xapian::QueryParser::set_max_wildcard_expansion(Xapian::termcount
5526        limit)
5527
5528        Note: you must also set FLAG_WILDCARD for wildcard expansion to
5529        happen.
5530
5531        Parameters:
5532        -----------
5533
5534        limit:  The maximum number of terms each wildcard in the query can
5535        expand to, or 0 for no limit (which is the default).
5536        """
5537        return _xapian.QueryParser_set_max_wildcard_expansion(self, *args)
5538
5539    def parse_query(self, *args):
5540        """
5541        Parse a query.
5542
5543        Query Xapian::QueryParser::parse_query(const std::string
5544        &query_string, unsigned flags=FLAG_DEFAULT, const std::string
5545        &default_prefix=std::string())
5546
5547        Parameters:
5548        -----------
5549
5550        query_string:  A free-text query as entered by a user
5551
5552        flags:  Zero or more QueryParser::feature_flag specifying what
5553        features the QueryParser should support. Combine multiple values with
5554        bitwise-or (|) (default FLAG_DEFAULT).
5555
5556        default_prefix:  The default term prefix to use (default none). For
5557        example, you can pass "A" when parsing an "Author" field.
5558
5559        Parameters:
5560        -----------
5561
5562        If:  the query string can't be parsed, then Xapian::QueryParserError
5563        is thrown. You can get an English error message to report to the user
5564        by catching it and calling get_msg() on the caught exception. The
5565        current possible values (in case you want to translate them) are:
5566
5567        Unknown range operation
5568
5569        parse error
5570
5571        Syntax: <expression> AND <expression>
5572
5573        Syntax: <expression> AND NOT <expression>
5574
5575        Syntax: <expression> NOT <expression>
5576
5577        Syntax: <expression> OR <expression>
5578
5579        Syntax: <expression> XOR <expression>
5580        """
5581        return _xapian.QueryParser_parse_query(self, *args)
5582
5583    def add_prefix(self, *args):
5584        """
5585        Add a probabilistic term prefix.
5586
5587        void Xapian::QueryParser::add_prefix(const std::string &field, const
5588        std::string &prefix)
5589
5590        For example:
5591
5592        This allows the user to search for author:Orwell which will be
5593        converted to a search for the term "Aorwell".
5594
5595        Multiple fields can be mapped to the same prefix. For example, you can
5596        make title: and subject: aliases for each other.
5597
5598        As of 1.0.4, you can call this method multiple times with the same
5599        value of field to allow a single field to be mapped to multiple
5600        prefixes. Multiple terms being generated for such a field, and
5601        combined with  Xapian::Query::OP_OR.
5602
5603        If any prefixes are specified for the empty field name (i.e. you call
5604        this method with an empty string as the first parameter) these
5605        prefixes will be used for terms without a field specifier. If you do
5606        this and also specify the default_prefix parameter to  parse_query(),
5607        then the default_prefix parameter will override.
5608
5609        If the prefix parameter is empty, then "field:word" will produce the
5610        term "word" (and this can be one of several prefixes for a
5611        particular field, or for terms without a field specifier).
5612
5613        If you call  add_prefix() and  add_boolean_prefix() for the same value
5614        of field, a  Xapian::InvalidOperationError exception will be thrown.
5615
5616        In 1.0.3 and earlier, subsequent calls to this method with the same
5617        value of field had no effect.
5618
5619        Parameters:
5620        -----------
5621
5622        field:  The user visible field name
5623
5624        prefix:  The term prefix to map this to
5625        """
5626        return _xapian.QueryParser_add_prefix(self, *args)
5627
5628    def add_boolean_prefix(self, *args):
5629        """
5630        void
5631        Xapian::QueryParser::add_boolean_prefix(const std::string &field,
5632        const std::string &prefix)
5633        """
5634        return _xapian.QueryParser_add_boolean_prefix(self, *args)
5635
5636    def stoplist_begin(self):
5637        """
5638        Iterate over terms omitted from the query as stopwords.
5639
5640        TermIterator Xapian::QueryParser::stoplist_begin() const
5641        """
5642        return _xapian.QueryParser_stoplist_begin(self)
5643
5644    def stoplist_end(self):
5645        """TermIterator Xapian::QueryParser::stoplist_end() const """
5646        return _xapian.QueryParser_stoplist_end(self)
5647
5648    def unstem_begin(self, *args):
5649        """
5650        Iterate over unstemmed forms of the given (stemmed) term used in the
5651        query.
5652
5653        TermIterator Xapian::QueryParser::unstem_begin(const std::string
5654        &term) const
5655        """
5656        return _xapian.QueryParser_unstem_begin(self, *args)
5657
5658    def unstem_end(self, *args):
5659        """
5660        TermIterator
5661        Xapian::QueryParser::unstem_end(const std::string &) const
5662        """
5663        return _xapian.QueryParser_unstem_end(self, *args)
5664
5665    def add_valuerangeprocessor(self, *args):
5666        """
5667        Register a ValueRangeProcessor.
5668
5669        void
5670        Xapian::QueryParser::add_valuerangeprocessor(Xapian::ValueRangeProcessor
5671        *vrproc)
5672        """
5673        return _xapian.QueryParser_add_valuerangeprocessor(self, *args)
5674
5675    def get_corrected_query_string(self):
5676        """
5677        Get the spelling-corrected query string.
5678
5679        std::string Xapian::QueryParser::get_corrected_query_string() const
5680
5681        This will only be set if FLAG_SPELLING_CORRECTION is specified when
5682        QueryParser::parse_query() was last called.
5683
5684        If there were no corrections, an empty string is returned.
5685        """
5686        return _xapian.QueryParser_get_corrected_query_string(self)
5687
5688    def __str__(self):
5689        """
5690        Return a string describing this object.
5691
5692        std::string Xapian::QueryParser::get_description() const
5693        """
5694        return _xapian.QueryParser___str__(self)
5695
5696QueryParser.set_stemmer = new_instancemethod(_xapian.QueryParser_set_stemmer,None,QueryParser)
5697QueryParser.set_stemming_strategy = new_instancemethod(_xapian.QueryParser_set_stemming_strategy,None,QueryParser)
5698QueryParser.set_stopper = new_instancemethod(_xapian.QueryParser_set_stopper,None,QueryParser)
5699QueryParser.set_default_op = new_instancemethod(_xapian.QueryParser_set_default_op,None,QueryParser)
5700QueryParser.get_default_op = new_instancemethod(_xapian.QueryParser_get_default_op,None,QueryParser)
5701QueryParser.set_database = new_instancemethod(_xapian.QueryParser_set_database,None,QueryParser)
5702QueryParser.set_max_wildcard_expansion = new_instancemethod(_xapian.QueryParser_set_max_wildcard_expansion,None,QueryParser)
5703QueryParser.parse_query = new_instancemethod(_xapian.QueryParser_parse_query,None,QueryParser)
5704QueryParser.add_prefix = new_instancemethod(_xapian.QueryParser_add_prefix,None,QueryParser)
5705QueryParser.add_boolean_prefix = new_instancemethod(_xapian.QueryParser_add_boolean_prefix,None,QueryParser)
5706QueryParser.stoplist_begin = new_instancemethod(_xapian.QueryParser_stoplist_begin,None,QueryParser)
5707QueryParser.stoplist_end = new_instancemethod(_xapian.QueryParser_stoplist_end,None,QueryParser)
5708QueryParser.unstem_begin = new_instancemethod(_xapian.QueryParser_unstem_begin,None,QueryParser)
5709QueryParser.unstem_end = new_instancemethod(_xapian.QueryParser_unstem_end,None,QueryParser)
5710QueryParser.add_valuerangeprocessor = new_instancemethod(_xapian.QueryParser_add_valuerangeprocessor,None,QueryParser)
5711QueryParser.get_corrected_query_string = new_instancemethod(_xapian.QueryParser_get_corrected_query_string,None,QueryParser)
5712QueryParser.__str__ = new_instancemethod(_xapian.QueryParser___str__,None,QueryParser)
5713QueryParser_swigregister = _xapian.QueryParser_swigregister
5714QueryParser_swigregister(QueryParser)
5715
5716
5717def sortable_serialise(*args):
5718  return _xapian.sortable_serialise(*args)
5719sortable_serialise = _xapian.sortable_serialise
5720
5721def sortable_unserialise(*args):
5722  return _xapian.sortable_unserialise(*args)
5723sortable_unserialise = _xapian.sortable_unserialise
5724class StemImplementation(object):
5725    """
5726    Class representing a stemming algorithm implementation.
5727    """
5728    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5729    __repr__ = _swig_repr
5730    __swig_destroy__ = _xapian.delete_StemImplementation
5731    def __str__(self):
5732        """
5733        Return a string describing this object.
5734
5735        virtual std::string Xapian::StemImplementation::get_description()
5736        const =0
5737        """
5738        return _xapian.StemImplementation___str__(self)
5739
5740    def __init__(self):
5741        if self.__class__ == StemImplementation:
5742            _self = None
5743        else:
5744            _self = self
5745        _xapian.StemImplementation_swiginit(self,_xapian.new_StemImplementation(_self, ))
5746    def __disown__(self):
5747        self.this.disown()
5748        _xapian.disown_StemImplementation(self)
5749        return weakref_proxy(self)
5750StemImplementation.__call__ = new_instancemethod(_xapian.StemImplementation___call__,None,StemImplementation)
5751StemImplementation.__str__ = new_instancemethod(_xapian.StemImplementation___str__,None,StemImplementation)
5752StemImplementation_swigregister = _xapian.StemImplementation_swigregister
5753StemImplementation_swigregister(StemImplementation)
5754
5755class Stem(object):
5756    """
5757    Class representing a stemming algorithm.
5758    """
5759    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5760    __repr__ = _swig_repr
5761    def __init__(self, *args):
5762        """
5763        Construct a Xapian::Stem object with a user-provided stemming
5764        algorithm.
5765
5766        Xapian::Stem::Stem(StemImplementation *p)
5767
5768        You can subclass Xapian::StemImplementation to implement your own
5769        stemming algorithm (or to wrap a third-party algorithm) and then wrap
5770        your implementation in a Xapian::Stem object to pass to the Xapian
5771        API.
5772
5773        Parameters:
5774        -----------
5775
5776        p:  The user-subclassed StemImplementation object. This is reference
5777        counted, and so will be automatically deleted by the Xapian::Stem
5778        wrapper when no longer required.
5779        """
5780        _xapian.Stem_swiginit(self,_xapian.new_Stem(*args))
5781    __swig_destroy__ = _xapian.delete_Stem
5782    def __str__(self):
5783        """
5784        Return a string describing this object.
5785
5786        std::string Xapian::Stem::get_description() const
5787        """
5788        return _xapian.Stem___str__(self)
5789
5790    get_available_languages = staticmethod(_xapian.Stem_get_available_languages)
5791Stem.__call__ = new_instancemethod(_xapian.Stem___call__,None,Stem)
5792Stem.__str__ = new_instancemethod(_xapian.Stem___str__,None,Stem)
5793Stem_swigregister = _xapian.Stem_swigregister
5794Stem_swigregister(Stem)
5795
5796def Stem_get_available_languages():
5797  return _xapian.Stem_get_available_languages()
5798Stem_get_available_languages = _xapian.Stem_get_available_languages
5799
5800class TermGenerator(object):
5801    """
5802    Parses a piece of text and generate terms.
5803
5804    This module takes a piece of text and parses it to produce words which
5805    are then used to generate suitable terms for indexing. The terms
5806    generated are suitable for use with Query objects produced by the
5807    QueryParser class.
5808    """
5809    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5810    __repr__ = _swig_repr
5811    def __init__(self):
5812        """
5813        Default constructor.
5814
5815        Xapian::TermGenerator::TermGenerator()
5816        """
5817        _xapian.TermGenerator_swiginit(self,_xapian.new_TermGenerator())
5818    __swig_destroy__ = _xapian.delete_TermGenerator
5819    def set_stemmer(self, *args):
5820        """
5821        Set the Xapian::Stem object to be used for generating stemmed terms.
5822
5823        void Xapian::TermGenerator::set_stemmer(const Xapian::Stem &stemmer)
5824
5825        """
5826        return _xapian.TermGenerator_set_stemmer(self, *args)
5827
5828    def set_stopper(self, stop=None):
5829        """
5830        Set the Xapian::Stopper object to be used for identifying stopwords.
5831
5832        void Xapian::TermGenerator::set_stopper(const Xapian::Stopper
5833        *stop=NULL)
5834
5835        Stemmed forms of stopwords aren't indexed, but unstemmed forms still
5836        are so that searches for phrases including stop words still work.
5837
5838        Parameters:
5839        -----------
5840
5841        stop:  The Stopper object to set (default NULL, which means no
5842        stopwords).
5843        """
5844        return _xapian.TermGenerator_set_stopper(self, stop)
5845
5846    def set_document(self, *args):
5847        """
5848        Set the current document.
5849
5850        void Xapian::TermGenerator::set_document(const Xapian::Document &doc)
5851
5852        """
5853        return _xapian.TermGenerator_set_document(self, *args)
5854
5855    def get_document(self):
5856        """
5857        Get the current document.
5858
5859        const Xapian::Document& Xapian::TermGenerator::get_document() const
5860        """
5861        return _xapian.TermGenerator_get_document(self)
5862
5863    def set_database(self, *args):
5864        """
5865        Set the database to index spelling data to.
5866
5867        void Xapian::TermGenerator::set_database(const
5868        Xapian::WritableDatabase &db)
5869        """
5870        return _xapian.TermGenerator_set_database(self, *args)
5871
5872    FLAG_SPELLING = _xapian.TermGenerator_FLAG_SPELLING
5873    FLAG_CJK_NGRAM = _xapian.TermGenerator_FLAG_CJK_NGRAM
5874    STEM_NONE = _xapian.TermGenerator_STEM_NONE
5875    STEM_SOME = _xapian.TermGenerator_STEM_SOME
5876    STEM_ALL = _xapian.TermGenerator_STEM_ALL
5877    STEM_ALL_Z = _xapian.TermGenerator_STEM_ALL_Z
5878    def set_flags(self, *args):
5879        """
5880        Set flags.
5881
5882        flags Xapian::TermGenerator::set_flags(flags toggle, flags
5883        mask=flags(0))
5884
5885        The new value of flags is: (flags & mask) ^ toggle
5886
5887        To just set the flags, pass the new flags in toggle and the default
5888        value for mask.
5889
5890        Parameters:
5891        -----------
5892
5893        toggle:  Flags to XOR.
5894
5895        mask:  Flags to AND with first.
5896
5897        The old flags setting.
5898        """
5899        return _xapian.TermGenerator_set_flags(self, *args)
5900
5901    def set_stemming_strategy(self, *args):
5902        """
5903        Set the stemming strategy.
5904
5905        void Xapian::TermGenerator::set_stemming_strategy(stem_strategy
5906        strategy)
5907
5908        This method controls how the stemming algorithm is applied. It was new
5909        in Xapian 1.3.1.
5910
5911        Parameters:
5912        -----------
5913
5914        strategy:  The strategy to use - possible values are: STEM_NONE: Don't
5915        perform any stemming - only unstemmed terms are generated.
5916
5917        STEM_SOME: Generate both stemmed (with a "Z" prefix) and unstemmed
5918        terms. This is the default strategy.
5919
5920        STEM_ALL: Generate only stemmed terms (but without a "Z" prefix).
5921
5922        STEM_ALL_Z: Generate only stemmed terms (with a "Z" prefix).
5923        """
5924        return _xapian.TermGenerator_set_stemming_strategy(self, *args)
5925
5926    def set_max_word_length(self, *args):
5927        """
5928        Set the maximum length word to index.
5929
5930        void Xapian::TermGenerator::set_max_word_length(unsigned
5931        max_word_length)
5932
5933        The limit is on the length of a word prior to stemming and prior to
5934        adding any term prefix.
5935
5936        The backends mostly impose a limit on the length of terms (often of
5937        about 240 bytes), but it's generally useful to have a lower limit to
5938        help prevent the index being bloated by useless junk terms from trying
5939        to indexing things like binary data, uuencoded data, ASCII art, etc.
5940
5941        This method was new in Xapian 1.3.1.
5942
5943        Parameters:
5944        -----------
5945
5946        max_word_length:  The maximum length word to index, in bytes in UTF-8
5947        representation. Default is 64.
5948        """
5949        return _xapian.TermGenerator_set_max_word_length(self, *args)
5950
5951    def index_text(self, *args):
5952        """
5953        Index some text in a std::string.
5954
5955        void Xapian::TermGenerator::index_text(const std::string &text,
5956        Xapian::termcount wdf_inc=1, const std::string &prefix=std::string())
5957
5958        Parameters:
5959        -----------
5960
5961        text:  The text to index.
5962
5963        wdf_inc:  The wdf increment (default 1).
5964
5965        prefix:  The term prefix to use (default is no prefix).
5966        """
5967        return _xapian.TermGenerator_index_text(self, *args)
5968
5969    def index_text_without_positions(self, *args):
5970        """
5971        Index some text in a std::string without positional information.
5972
5973        void Xapian::TermGenerator::index_text_without_positions(const
5974        std::string &text, Xapian::termcount wdf_inc=1, const std::string
5975        &prefix=std::string())
5976
5977        Just like index_text, but no positional information is generated. This
5978        means that the database will be significantly smaller, but that phrase
5979        searching and NEAR won't be supported.
5980
5981        Parameters:
5982        -----------
5983
5984        text:  The text to index.
5985
5986        wdf_inc:  The wdf increment (default 1).
5987
5988        prefix:  The term prefix to use (default is no prefix).
5989        """
5990        return _xapian.TermGenerator_index_text_without_positions(self, *args)
5991
5992    def increase_termpos(self, delta=100):
5993        """
5994        Increase the term position used by index_text.
5995
5996        void Xapian::TermGenerator::increase_termpos(Xapian::termcount
5997        delta=100)
5998
5999        This can be used between indexing text from different fields or other
6000        places to prevent phrase searches from spanning between them (e.g.
6001        between the title and body text, or between two chapters in a book).
6002
6003        Parameters:
6004        -----------
6005
6006        delta:  Amount to increase the term position by (default: 100).
6007        """
6008        return _xapian.TermGenerator_increase_termpos(self, delta)
6009
6010    def get_termpos(self):
6011        """
6012        Get the current term position.
6013
6014        Xapian::termcount Xapian::TermGenerator::get_termpos() const
6015        """
6016        return _xapian.TermGenerator_get_termpos(self)
6017
6018    def set_termpos(self, *args):
6019        """
6020        Set the current term position.
6021
6022        void Xapian::TermGenerator::set_termpos(Xapian::termcount termpos)
6023
6024        Parameters:
6025        -----------
6026
6027        termpos:  The new term position to set.
6028        """
6029        return _xapian.TermGenerator_set_termpos(self, *args)
6030
6031    def __str__(self):
6032        """
6033        Return a string describing this object.
6034
6035        std::string Xapian::TermGenerator::get_description() const
6036        """
6037        return _xapian.TermGenerator___str__(self)
6038
6039TermGenerator.set_stemmer = new_instancemethod(_xapian.TermGenerator_set_stemmer,None,TermGenerator)
6040TermGenerator.set_stopper = new_instancemethod(_xapian.TermGenerator_set_stopper,None,TermGenerator)
6041TermGenerator.set_document = new_instancemethod(_xapian.TermGenerator_set_document,None,TermGenerator)
6042TermGenerator.get_document = new_instancemethod(_xapian.TermGenerator_get_document,None,TermGenerator)
6043TermGenerator.set_database = new_instancemethod(_xapian.TermGenerator_set_database,None,TermGenerator)
6044TermGenerator.set_flags = new_instancemethod(_xapian.TermGenerator_set_flags,None,TermGenerator)
6045TermGenerator.set_stemming_strategy = new_instancemethod(_xapian.TermGenerator_set_stemming_strategy,None,TermGenerator)
6046TermGenerator.set_max_word_length = new_instancemethod(_xapian.TermGenerator_set_max_word_length,None,TermGenerator)
6047TermGenerator.index_text = new_instancemethod(_xapian.TermGenerator_index_text,None,TermGenerator)
6048TermGenerator.index_text_without_positions = new_instancemethod(_xapian.TermGenerator_index_text_without_positions,None,TermGenerator)
6049TermGenerator.increase_termpos = new_instancemethod(_xapian.TermGenerator_increase_termpos,None,TermGenerator)
6050TermGenerator.get_termpos = new_instancemethod(_xapian.TermGenerator_get_termpos,None,TermGenerator)
6051TermGenerator.set_termpos = new_instancemethod(_xapian.TermGenerator_set_termpos,None,TermGenerator)
6052TermGenerator.__str__ = new_instancemethod(_xapian.TermGenerator___str__,None,TermGenerator)
6053TermGenerator_swigregister = _xapian.TermGenerator_swigregister
6054TermGenerator_swigregister(TermGenerator)
6055
6056class KeyMaker(object):
6057    """
6058    Virtual base class for key making functors.
6059    """
6060    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
6061    __repr__ = _swig_repr
6062    __swig_destroy__ = _xapian.delete_KeyMaker
6063    def __init__(self):
6064        if self.__class__ == KeyMaker:
6065            _self = None
6066        else:
6067            _self = self
6068        _xapian.KeyMaker_swiginit(self,_xapian.new_KeyMaker(_self, ))
6069    def __disown__(self):
6070        self.this.disown()
6071        _xapian.disown_KeyMaker(self)
6072        return weakref_proxy(self)
6073KeyMaker.__call__ = new_instancemethod(_xapian.KeyMaker___call__,None,KeyMaker)
6074KeyMaker_swigregister = _xapian.KeyMaker_swigregister
6075KeyMaker_swigregister(KeyMaker)
6076
6077class MultiValueKeyMaker(KeyMaker):
6078    """
6079    KeyMaker subclass which combines several values.
6080
6081    When the result is used for sorting, results are ordered by the first
6082    value. In the event of a tie, the second is used. If this is the same
6083    for both, the third is used, and so on. If reverse is true for a
6084    value, then the sort order for that value is reversed.
6085
6086    When used for collapsing, the documents will only be considered equal
6087    if all the values specified match. If none of the specified values are
6088    set then the generated key will be empty, so such documents won't be
6089    collapsed (which is consistent with the behaviour in the "collapse on
6090    a value" case). If you'd prefer that documents with none of the keys
6091    set are collapsed together, then you can set reverse for at least one
6092    of the values. Other than this, it isn't useful to set reverse for
6093    collapsing.
6094    """
6095    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
6096    __repr__ = _swig_repr
6097    def __init__(self):
6098        """
6099        Xapian::MultiValueKeyMaker::MultiValueKeyMaker(Iterator begin,
6100        Iterator end)
6101        """
6102        _xapian.MultiValueKeyMaker_swiginit(self,_xapian.new_MultiValueKeyMaker())
6103    def add_value(self, *args):
6104        """
6105        void
6106        Xapian::MultiValueKeyMaker::add_value(Xapian::valueno slot, bool
6107        reverse=false)
6108        """
6109        return _xapian.MultiValueKeyMaker_add_value(self, *args)
6110
6111    __swig_destroy__ = _xapian.delete_MultiValueKeyMaker
6112MultiValueKeyMaker.add_value = new_instancemethod(_xapian.MultiValueKeyMaker_add_value,None,MultiValueKeyMaker)
6113MultiValueKeyMaker_swigregister = _xapian.MultiValueKeyMaker_swigregister
6114MultiValueKeyMaker_swigregister(MultiValueKeyMaker)
6115
6116class Sorter(KeyMaker):
6117    """
6118    Virtual base class for sorter functor.
6119    """
6120    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
6121    def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract")
6122    __repr__ = _swig_repr
6123    __swig_destroy__ = _xapian.delete_Sorter
6124Sorter_swigregister = _xapian.Sorter_swigregister
6125Sorter_swigregister(Sorter)
6126
6127class MultiValueSorter(Sorter):
6128    """
6129    Sorter subclass which sorts by a several values.
6130
6131    Results are ordered by the first value. In the event of a tie, the
6132    second is used. If this is the same for both, the third is used, and
6133    so on.
6134
6135    Deprecated This class is deprecated - you should migrate to using
6136    MultiValueKeyMaker instead. Note that MultiValueSorter::add() becomes
6137    MultiValueKeyMaker::add_value(), but the sense of the direction flag
6138    is reversed (to be consistent with Enquire::set_sort_by_value()).
6139
6140    So: MultiValueSorter sorter;     // Primary ordering is forwards on
6141    value 4. sorter.add(4);     // Secondary ordering is reverse on value
6142    5. sorter.add(5, false); becomes: MultiValueKeyMaker sorter;     //
6143    Primary ordering is forwards on value 4. sorter.add_value(4);     //
6144    Secondary ordering is reverse on value 5. sorter.add_value(5, true);
6145
6146    """
6147    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
6148    __repr__ = _swig_repr
6149    def __init__(self):
6150        """
6151        Xapian::MultiValueSorter::MultiValueSorter(Iterator begin, Iterator
6152        end)
6153        """
6154        _xapian.MultiValueSorter_swiginit(self,_xapian.new_MultiValueSorter())
6155    def add(self, *args):
6156        """
6157        void
6158        Xapian::MultiValueSorter::add(Xapian::valueno slot, bool forward=true)
6159
6160        """
6161        return _xapian.MultiValueSorter_add(self, *args)
6162
6163    __swig_destroy__ = _xapian.delete_MultiValueSorter
6164MultiValueSorter.add = new_instancemethod(_xapian.MultiValueSorter_add,None,MultiValueSorter)
6165MultiValueSorter_swigregister = _xapian.MultiValueSorter_swigregister
6166MultiValueSorter_swigregister(MultiValueSorter)
6167
6168class ValueSetMatchDecider(MatchDecider):
6169    """
6170    MatchDecider filtering results based on whether document values are in
6171    a user- defined set.
6172    """
6173    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
6174    __repr__ = _swig_repr
6175    def __init__(self, *args):
6176        """
6177        Construct a ValueSetMatchDecider.
6178
6179        Xapian::ValueSetMatchDecider::ValueSetMatchDecider(Xapian::valueno
6180        slot, bool inclusive_)
6181
6182        Parameters:
6183        -----------
6184
6185        slot:  The value slot number to look in.
6186
6187        inclusive_:  If true, match decider accepts documents which have a
6188        value in the specified slot which is a member of the test set; if
6189        false, match decider accepts documents which do not have a value in
6190        the specified slot.
6191        """
6192        _xapian.ValueSetMatchDecider_swiginit(self,_xapian.new_ValueSetMatchDecider(*args))
6193    def add_value(self, *args):
6194        """
6195        Add a value to the test set.
6196
6197        void Xapian::ValueSetMatchDecider::add_value(const std::string &value)
6198
6199        Parameters:
6200        -----------
6201
6202        value:  The value to add to the test set.
6203        """
6204        return _xapian.ValueSetMatchDecider_add_value(self, *args)
6205
6206    def remove_value(self, *args):
6207        """
6208        Remove a value from the test set.
6209
6210        void Xapian::ValueSetMatchDecider::remove_value(const std::string
6211        &value)
6212
6213        Parameters:
6214        -----------
6215
6216        value:  The value to remove from the test set.
6217        """
6218        return _xapian.ValueSetMatchDecider_remove_value(self, *args)
6219
6220    __swig_destroy__ = _xapian.delete_ValueSetMatchDecider
6221ValueSetMatchDecider.add_value = new_instancemethod(_xapian.ValueSetMatchDecider_add_value,None,ValueSetMatchDecider)
6222ValueSetMatchDecider.remove_value = new_instancemethod(_xapian.ValueSetMatchDecider_remove_value,None,ValueSetMatchDecider)
6223ValueSetMatchDecider_swigregister = _xapian.ValueSetMatchDecider_swigregister
6224ValueSetMatchDecider_swigregister(ValueSetMatchDecider)
6225
6226class Compactor(object):
6227    """
6228    Compact a database, or merge and compact several.
6229    """
6230    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
6231    __repr__ = _swig_repr
6232    STANDARD = _xapian.Compactor_STANDARD
6233    FULL = _xapian.Compactor_FULL
6234    FULLER = _xapian.Compactor_FULLER
6235    def __init__(self):
6236        """Xapian::Compactor::Compactor() """
6237        if self.__class__ == Compactor:
6238            _self = None
6239        else:
6240            _self = self
6241        _xapian.Compactor_swiginit(self,_xapian.new_Compactor(_self, ))
6242    __swig_destroy__ = _xapian.delete_Compactor
6243    def set_block_size(self, *args):
6244        """
6245        Set the block size to use for tables in the output database.
6246
6247        void Xapian::Compactor::set_block_size(size_t block_size)
6248
6249        Parameters:
6250        -----------
6251
6252        block_size:  The block size to use. Valid block sizes are currently
6253        powers of two between 2048 and 65536, with the default being 8192, but
6254        the valid sizes and default may change in the future.
6255        """
6256        return _xapian.Compactor_set_block_size(self, *args)
6257
6258    def set_renumber(self, *args):
6259        """
6260        Set whether to preserve existing document id values.
6261
6262        void Xapian::Compactor::set_renumber(bool renumber)
6263
6264        Parameters:
6265        -----------
6266
6267        renumber:  The default is true, which means that document ids will be
6268        renumbered - currently by applying the same offset to all the document
6269        ids in a particular source database.
6270
6271        If false, then the document ids must be unique over all source
6272        databases. Currently the ranges of document ids in each source must
6273        not overlap either, though this restriction may be removed in the
6274        future.
6275        """
6276        return _xapian.Compactor_set_renumber(self, *args)
6277
6278    def set_multipass(self, *args):
6279        """
6280        Set whether to merge postlists in multiple passes.
6281
6282        void Xapian::Compactor::set_multipass(bool multipass)
6283
6284        Parameters:
6285        -----------
6286
6287        multipass:  If true and merging more than 3 databases, merge the
6288        postlists in multiple passes, which is generally faster but requires
6289        more disk space for temporary files. By default we don't do this.
6290        """
6291        return _xapian.Compactor_set_multipass(self, *args)
6292
6293    def set_compaction_level(self, *args):
6294        """
6295        Set the compaction level.
6296
6297        void Xapian::Compactor::set_compaction_level(compaction_level
6298        compaction)
6299
6300        Parameters:
6301        -----------
6302
6303        compaction:  Available values are: Xapian::Compactor::STANDARD - Don't
6304        split items unnecessarily.
6305
6306        Xapian::Compactor::FULL - Split items whenever it saves space (the
6307        default).
6308
6309        Xapian::Compactor::FULLER - Allow oversize items to save more space
6310        (not recommended if you ever plan to update the compacted database).
6311
6312        """
6313        return _xapian.Compactor_set_compaction_level(self, *args)
6314
6315    def set_destdir(self, *args):
6316        """
6317        Set where to write the output.
6318
6319        void Xapian::Compactor::set_destdir(const std::string &destdir)
6320
6321        Parameters:
6322        -----------
6323
6324        destdir:  Output path. This can be the same as an input if that input
6325        is a stub database (in which case the database(s) listed in the stub
6326        will be compacted to a new database and then the stub will be
6327        atomically updated to point to this new database).
6328        """
6329        return _xapian.Compactor_set_destdir(self, *args)
6330
6331    def add_source(self, *args):
6332        """
6333        Add a source database.
6334
6335        void Xapian::Compactor::add_source(const std::string &srcdir)
6336
6337        Parameters:
6338        -----------
6339
6340        srcdir:  The path to the source database to add.
6341        """
6342        return _xapian.Compactor_add_source(self, *args)
6343
6344    def compact(self):
6345        """
6346        Perform the actual compaction/merging operation.
6347
6348        void Xapian::Compactor::compact()
6349        """
6350        return _xapian.Compactor_compact(self)
6351
6352    def set_status(self, *args):
6353        """
6354        Update progress.
6355
6356        virtual void Xapian::Compactor::set_status(const std::string &table,
6357        const std::string &status)
6358
6359        Subclass this method if you want to get progress updates during
6360        compaction. This is called for each table first with empty status, And
6361        then one or more times with non-empty status.
6362
6363        The default implementation does nothing.
6364
6365        Parameters:
6366        -----------
6367
6368        table:  The table currently being compacted.
6369
6370        status:  A status message.
6371        """
6372        return _xapian.Compactor_set_status(self, *args)
6373
6374    def resolve_duplicate_metadata(self, *args):
6375        """
6376        Resolve multiple user metadata entries with the same key.
6377
6378        virtual std::string
6379        Xapian::Compactor::resolve_duplicate_metadata(const std::string &key,
6380        size_t num_tags, const std::string tags[])
6381
6382        When merging, if the same user metadata key is set in more than one
6383        input, then this method is called to allow this to be resolving in an
6384        appropriate way.
6385
6386        The default implementation just returns tags[0].
6387
6388        For multipass this will currently get called multiple times for the
6389        same key if there are duplicates to resolve in each pass, but this may
6390        change in the future.
6391
6392        Parameters:
6393        -----------
6394
6395        key:  The metadata key with duplicate entries.
6396
6397        num_tags:  How many tags there are.
6398
6399        tags:  An array of num_tags strings containing the tags to merge.
6400        """
6401        return _xapian.Compactor_resolve_duplicate_metadata(self, *args)
6402
6403    def __disown__(self):
6404        self.this.disown()
6405        _xapian.disown_Compactor(self)
6406        return weakref_proxy(self)
6407Compactor.set_block_size = new_instancemethod(_xapian.Compactor_set_block_size,None,Compactor)
6408Compactor.set_renumber = new_instancemethod(_xapian.Compactor_set_renumber,None,Compactor)
6409Compactor.set_multipass = new_instancemethod(_xapian.Compactor_set_multipass,None,Compactor)
6410Compactor.set_compaction_level = new_instancemethod(_xapian.Compactor_set_compaction_level,None,Compactor)
6411Compactor.set_destdir = new_instancemethod(_xapian.Compactor_set_destdir,None,Compactor)
6412Compactor.add_source = new_instancemethod(_xapian.Compactor_add_source,None,Compactor)
6413Compactor.compact = new_instancemethod(_xapian.Compactor_compact,None,Compactor)
6414Compactor.set_status = new_instancemethod(_xapian.Compactor_set_status,None,Compactor)
6415Compactor.resolve_duplicate_metadata = new_instancemethod(_xapian.Compactor_resolve_duplicate_metadata,None,Compactor)
6416Compactor_swigregister = _xapian.Compactor_swigregister
6417Compactor_swigregister(Compactor)
6418
6419# Set the documentation format - this is used by tools like "epydoc" to decide
6420# how to format the documentation strings.
6421__docformat__ = "restructuredtext en"
6422
6423##################################
6424# Support for iteration of MSets #
6425##################################
6426
6427class MSetItem(object):
6428    """An item returned from iteration of the MSet.
6429
6430    The item supports access to the following attributes and properties:
6431
6432     - `docid`: The Xapian document ID corresponding to this MSet item.
6433     - `weight`: The weight corresponding to this MSet item.
6434     - `rank`: The rank of this MSet item.  The rank is the position in the
6435       total set of matching documents of this item.  The highest document is
6436       given a rank of 0.  If the MSet did not start at the highest matching
6437       document, because a non-zero 'start' parameter was supplied to
6438       get_mset(), the first document in the MSet will have a rank greater than
6439       0 (in fact, it will be equal to the value of 'start' supplied to
6440       get_mset()).
6441     - `percent`: The percentage score assigned to this MSet item.
6442     - `document`: The document for this MSet item.  This can be used to access
6443       the document data, or any other information stored in the document (such
6444       as term lists).  It is lazily evaluated.
6445     - `collapse_key`: The value of the key which was used for collapsing.
6446     - `collapse_count`: An estimate of the number of documents that have been
6447       collapsed into this one.
6448
6449    The collapse count estimate will always be less than or equal to the actual
6450    number of other documents satisfying the match criteria with the same
6451    collapse key as this document.  If may be 0 even though there are other
6452    documents with the same collapse key which satisfying the match criteria.
6453    However if this method returns non-zero, there definitely are other such
6454    documents.  So this method may be used to inform the user that there are
6455    "at least N other matches in this group", or to control whether to offer a
6456    "show other documents in this group" feature (but note that it may not
6457    offer it in every case where it would show other documents).
6458
6459    """
6460
6461    __slots__ = ('_mset', '_firstitem', 'docid', 'weight', 'rank',
6462                 'percent', 'collapse_key', 'collapse_count', '_document', )
6463
6464    def __init__(self, iter, mset):
6465        self._mset = mset
6466        self._firstitem = self._mset.get_firstitem()
6467        self.docid = iter.get_docid()
6468        self.weight = iter.get_weight()
6469        self.rank = iter.get_rank()
6470        self.percent = iter.get_percent()
6471        self.collapse_key = iter.get_collapse_key()
6472        self.collapse_count = iter.get_collapse_count()
6473        self._document = None
6474
6475    def _get_document(self):
6476        if self._document is None:
6477            self._document = self._mset._get_hit_internal(self.rank - self._firstitem).get_document()
6478        return self._document
6479
6480    document = property(_get_document, doc="The document object corresponding to this MSet item.")
6481
6482class MSetIter(object):
6483    """An iterator over the items in an MSet.
6484
6485    The iterator will return MSetItem objects, which will be evaluated lazily
6486    where appropriate.
6487
6488    """
6489    __slots__ = ('_iter', '_end', '_mset')
6490    def __init__(self, mset):
6491        self._iter = mset.begin()
6492        self._end = mset.end()
6493        self._mset = mset
6494
6495    def __iter__(self):
6496        return self
6497
6498    # For Python2:
6499    def next(self):
6500        if self._iter == self._end:
6501            raise StopIteration
6502        else:
6503            r = MSetItem(self._iter, self._mset)
6504            self._iter.next()
6505            return r
6506
6507    # For Python3:
6508    def __next__(self):
6509        if self._iter == self._end:
6510            raise StopIteration
6511        else:
6512            r = MSetItem(self._iter, self._mset)
6513            next(self._iter)
6514            return r
6515
6516
6517# Modify the MSet to allow access to the python iterators, and have other
6518# convenience methods.
6519
6520def _mset_gen_iter(self):
6521    """Return an iterator over the MSet.
6522
6523    The iterator will return MSetItem objects, which will be evaluated lazily
6524    where appropriate.
6525
6526    """
6527    return MSetIter(self)
6528MSet.__iter__ = _mset_gen_iter
6529
6530MSet.__len__ = lambda self: MSet.size(self)
6531
6532def _mset_getitem(self, index):
6533    """Get an item from the MSet.
6534
6535    The supplied index is relative to the start of the MSet, not the absolute
6536    rank of the item.
6537
6538    Returns an MSetItem.
6539
6540    """
6541    if index < 0:
6542        index += len(self)
6543    if index < 0 or index >= len(self):
6544        raise IndexError("Mset index out of range")
6545    return MSetItem(self._get_hit_internal(index), self)
6546MSet.__getitem__ = _mset_getitem
6547MSet.get_hit = _mset_getitem
6548
6549
6550##################################
6551# Support for iteration of ESets #
6552##################################
6553
6554class ESetItem(object):
6555    """An item returned from iteration of the ESet.
6556
6557    The item supports access to the following attributes:
6558
6559     - `term`: The term corresponding to this ESet item.
6560     - `weight`: The weight corresponding to this ESet item.
6561
6562    """
6563    __slots__ = ('term', 'weight')
6564
6565    def __init__(self, iter):
6566        self.term = iter.get_term()
6567        self.weight = iter.get_weight()
6568
6569class ESetIter(object):
6570    """An iterator over the items in an ESet.
6571
6572    The iterator will return ESetItem objects.
6573
6574    """
6575    __slots__ = ('_iter', '_end')
6576    def __init__(self, eset):
6577        self._iter = eset.begin()
6578        self._end = eset.end()
6579
6580    def __iter__(self):
6581        return self
6582
6583    # For Python2:
6584    def next(self):
6585        if self._iter == self._end:
6586            raise StopIteration
6587        else:
6588            r = ESetItem(self._iter)
6589            self._iter.next()
6590            return r
6591
6592    # For Python3:
6593    def __next__(self):
6594        if self._iter == self._end:
6595            raise StopIteration
6596        else:
6597            r = ESetItem(self._iter)
6598            next(self._iter)
6599            return r
6600
6601# Modify the ESet to allow access to the python iterators, and have other
6602# convenience methods.
6603
6604def _eset_gen_iter(self):
6605    """Return an iterator over the ESet.
6606
6607    The iterator will return ESetItem objects.
6608
6609    """
6610    return ESetIter(self)
6611ESet.__iter__ = _eset_gen_iter
6612
6613ESet.__len__ = lambda self: ESet.size(self)
6614
6615
6616#######################################
6617# Support for iteration of term lists #
6618#######################################
6619
6620class TermListItem(object):
6621    """An item returned from iteration of a term list.
6622
6623    The item supports access to the following attributes and properties:
6624
6625     - `term`: The term corresponding to this TermListItem.
6626     - `wdf`: The within document frequency of this term.
6627     - `termfreq`: The number of documents in the collection which are indexed
6628       by the term
6629     - `positer`: An iterator over the positions which the term appears at in
6630       the document.  This is only available until the iterator which returned
6631       this item next moves.
6632
6633    """
6634    __slots__ = ('_iter', 'term', '_wdf', '_termfreq')
6635
6636    def __init__(self, iter, term):
6637        self._iter = iter
6638        self.term = term
6639        self._wdf = None
6640        self._termfreq = None
6641
6642        if iter._has_wdf == TermIter.EAGER:
6643            self._wdf = iter._iter.get_wdf()
6644        if iter._has_termfreq == TermIter.EAGER:
6645            self._termfreq = iter._iter.get_termfreq()
6646
6647        # Support for sequence API
6648        sequence = ['term', 'wdf', 'termfreq', 'positer']
6649        if iter._has_wdf == TermIter.INVALID:
6650            sequence[1] = 0
6651        if iter._has_termfreq == TermIter.INVALID:
6652            sequence[2] = 0
6653        if iter._has_positions == TermIter.INVALID:
6654            sequence[3] = PositionIter()
6655
6656    def _get_wdf(self):
6657        """Get the within-document-frequency of the current term.
6658
6659        This will raise a InvalidOperationError exception if the iterator this
6660        item came from doesn't support within-document-frequencies.
6661
6662        """
6663        if self._wdf is None:
6664            if self._iter._has_wdf == TermIter.INVALID:
6665                raise InvalidOperationError("Iterator does not support wdfs")
6666            if self.term is not self._iter._lastterm:
6667                raise InvalidOperationError("Iterator has moved, and does not support random access")
6668            self._wdf = self._iter._iter.get_wdf()
6669        return self._wdf
6670    wdf = property(_get_wdf, doc=
6671    """The within-document-frequency of the current term (if meaningful).
6672
6673    This will raise a InvalidOperationError exception if the iterator
6674    this item came from doesn't support within-document-frequencies.
6675
6676    """)
6677
6678    def _get_termfreq(self):
6679        """Get the term frequency.
6680
6681        This is the number of documents in the collection which are indexed by
6682        the term.
6683
6684        This will raise a InvalidOperationError exception if the iterator this
6685        item came from doesn't support term frequencies.
6686
6687        """
6688        if self._termfreq is None:
6689            if self._iter._has_termfreq == TermIter.INVALID:
6690                raise InvalidOperationError("Iterator does not support term frequencies")
6691            if self.term is not self._iter._lastterm:
6692                raise InvalidOperationError("Iterator has moved, and does not support random access")
6693            self._termfreq = self._iter._iter.get_termfreq()
6694        return self._termfreq
6695    termfreq = property(_get_termfreq, doc=
6696    """The term frequency of the current term (if meaningful).
6697
6698    This is the number of documents in the collection which are indexed by the
6699    term.
6700
6701    This will raise a InvalidOperationError exception if the iterator
6702    this item came from doesn't support term frequencies.
6703
6704    """)
6705
6706    def _get_positer(self):
6707        """Get a position list iterator.
6708
6709        The iterator will return integers representing the positions that the
6710        term occurs at.
6711
6712        This will raise a InvalidOperationError exception if the iterator this
6713        item came from doesn't support position lists, or if the iterator has
6714        moved on since the item was returned from it.
6715
6716        """
6717        if self._iter._has_positions == TermIter.INVALID:
6718            raise InvalidOperationError("Iterator does not support position lists")
6719        # Access to position lists is always lazy, so we don't need to check
6720        # _has_positions.
6721        if self.term is not self._iter._lastterm:
6722            raise InvalidOperationError("Iterator has moved, and does not support random access")
6723        return PositionIter(self._iter._iter.positionlist_begin(),
6724                            self._iter._iter.positionlist_end())
6725    positer = property(_get_positer, doc=
6726    """A position iterator for the current term (if meaningful).
6727
6728    The iterator will return integers representing the positions that the term
6729    occurs at.
6730
6731    This will raise a InvalidOperationError exception if the iterator this item
6732    came from doesn't support position lists, or if the iterator has moved on
6733    since the item was returned from it.
6734
6735    """)
6736
6737
6738class TermIter(object):
6739    """An iterator over a term list.
6740
6741    The iterator will return TermListItem objects, which will be evaluated
6742    lazily where appropriate.
6743
6744    """
6745    __slots__ = ('_iter', '_end', '_has_termfreq', '_has_wdf',
6746                 '_has_positions', '_return_strings', '_lastterm', '_moved')
6747
6748    INVALID = 0
6749    LAZY = 1
6750    EAGER = 2
6751
6752    def __init__(self, start, end, has_termfreq=INVALID,
6753                 has_wdf=INVALID, has_positions=INVALID,
6754                 return_strings=False):
6755        self._iter = start
6756        self._end = end
6757        self._has_termfreq = has_termfreq
6758        self._has_wdf = has_wdf
6759        self._has_positions = has_positions
6760        assert(has_positions != TermIter.EAGER) # Can't do eager access to position lists
6761        self._return_strings = return_strings
6762        self._lastterm = None # Used to test if the iterator has moved
6763
6764        # _moved is True if we've moved onto the next item.  This is needed so
6765        # that the iterator doesn't have to move on until just before next() is
6766        # called: since the iterator starts by pointing at a valid item, we
6767        # can't just call self._iter.next() unconditionally at the start of our
6768        # next() method.
6769        self._moved = True
6770
6771    def __iter__(self):
6772        return self
6773
6774    # For Python2:
6775    def next(self):
6776        if not self._moved:
6777            self._iter.next()
6778            self._moved = True
6779
6780        if self._iter == self._end:
6781            self._lastterm = None
6782            raise StopIteration
6783        else:
6784            self._lastterm = self._iter.get_term()
6785            self._moved = False
6786            if self._return_strings:
6787                return self._lastterm
6788            return TermListItem(self, self._lastterm)
6789
6790    # For Python3:
6791    def __next__(self):
6792        if not self._moved:
6793            next(self._iter)
6794            self._moved = True
6795
6796        if self._iter == self._end:
6797            self._lastterm = None
6798            raise StopIteration
6799        else:
6800            self._lastterm = self._iter.get_term()
6801            self._moved = False
6802            if self._return_strings:
6803                return self._lastterm
6804            return TermListItem(self, self._lastterm)
6805
6806    def skip_to(self, term):
6807        """Skip the iterator forward.
6808
6809        The iterator is advanced to the first term at or after the current
6810        position which is greater than or equal to the supplied term.
6811
6812        If there are no such items, this will raise StopIteration.
6813
6814        This returns the item which the iterator is moved to.  The subsequent
6815        item will be returned the next time that next() is called (unless
6816        skip_to() is called again first).
6817
6818        """
6819        if self._iter != self._end:
6820            self._iter.skip_to(term)
6821
6822        if self._iter == self._end:
6823            self._lastterm = None
6824            self._moved = True
6825            raise StopIteration
6826
6827        # Update self._lastterm if the iterator has moved.
6828        # TermListItems compare a saved value of lastterm with self._lastterm
6829        # with the object identity comparator, so it is important to ensure
6830        # that it does not get modified if the new term compares equal.
6831        newterm = self._iter.get_term()
6832        if newterm != self._lastterm:
6833            self._lastterm = newterm
6834
6835        self._moved = False
6836        if self._return_strings:
6837            return self._lastterm
6838        return TermListItem(self, self._lastterm)
6839
6840# Modify Enquire to add a "matching_terms()" method.
6841def _enquire_gen_iter(self, which):
6842    """Get an iterator over the terms which match a given match set item.
6843
6844    The match set item to consider is specified by the `which` parameter, which
6845    may be a document ID, or an MSetItem object.
6846
6847    The iterator will return string objects.
6848
6849    """
6850    if isinstance(which, MSetItem):
6851        which = which.docid
6852    return TermIter(self.get_matching_terms_begin(which),
6853                    self.get_matching_terms_end(which),
6854                    return_strings=True)
6855Enquire.matching_terms = _enquire_gen_iter
6856
6857# Modify Query to add an "__iter__()" method.
6858def _query_gen_iter(self):
6859    """Get an iterator over the terms in a query.
6860
6861    The iterator will return string objects.
6862
6863    """
6864    return TermIter(self.get_terms_begin(),
6865                    self.get_terms_end(),
6866                    return_strings=True)
6867Query.__iter__ = _query_gen_iter
6868
6869# Modify Database to add an "__iter__()" method and an "allterms()" method.
6870def _database_gen_allterms_iter(self, prefix=None):
6871    """Get an iterator over all the terms in the database.
6872
6873    The iterator will return TermListItem objects, but these will not support
6874    access to wdf, or position information.
6875
6876    Access to term frequency information is only available until the iterator
6877    has moved on.
6878
6879    If prefix is supplied, only terms which start with that prefix will be
6880    returned.
6881
6882    """
6883    if prefix is None:
6884        return TermIter(self.allterms_begin(), self.allterms_end(),
6885                        has_termfreq=TermIter.LAZY)
6886    else:
6887        return TermIter(self.allterms_begin(prefix), self.allterms_end(prefix),
6888                        has_termfreq=TermIter.LAZY)
6889Database.__iter__ = _database_gen_allterms_iter
6890Database.allterms = _database_gen_allterms_iter
6891
6892# Modify Database to add a "termlist()" method.
6893def _database_gen_termlist_iter(self, docid):
6894    """Get an iterator over all the terms which index a given document ID.
6895
6896    The iterator will return TermListItem objects.
6897
6898    Access to term frequency and position information is only available until
6899    the iterator has moved on.
6900
6901    """
6902    # Note: has_termfreq is set to LAZY because most databases don't store term
6903    # frequencies in the termlist (because this would require updating many termlist
6904    # entries for every document update), so access to the term frequency requires a
6905    # separate lookup.
6906    return TermIter(self.termlist_begin(docid), self.termlist_end(docid),
6907                    has_termfreq=TermIter.LAZY,
6908                    has_wdf=TermIter.EAGER,
6909                    has_positions=TermIter.LAZY)
6910Database.termlist = _database_gen_termlist_iter
6911
6912# Modify Database to add a "spellings()" method.
6913def _database_gen_spellings_iter(self):
6914    """Get an iterator which returns all the spelling correction targets
6915
6916    The iterator will return TermListItem objects.  Only the term frequency is
6917    available; wdf and positions are not meaningful.
6918
6919    """
6920    return TermIter(self.spellings_begin(), self.spellings_end(),
6921                    has_termfreq=TermIter.EAGER,
6922                    has_wdf=TermIter.INVALID,
6923                    has_positions=TermIter.INVALID)
6924Database.spellings = _database_gen_spellings_iter
6925
6926# Modify Database to add a "synonyms()" method.
6927def _database_gen_synonyms_iter(self, term):
6928    """Get an iterator which returns all the synonyms for a given term.
6929
6930    The term to return synonyms for is specified by the `term` parameter.
6931
6932    The iterator will return string objects.
6933
6934    """
6935    return TermIter(self.synonyms_begin(term),
6936                    self.synonyms_end(term),
6937                    return_strings=True)
6938Database.synonyms = _database_gen_synonyms_iter
6939
6940# Modify Database to add a "synonym_keys()" method.
6941def _database_gen_synonym_keys_iter(self, prefix=""):
6942    """Get an iterator which returns all the terms which have synonyms.
6943
6944    The iterator will return string objects.
6945
6946    If `prefix` is non-empty, only terms with this prefix are returned.
6947
6948    """
6949    return TermIter(self.synonym_keys_begin(prefix),
6950                    self.synonym_keys_end(prefix),
6951                    return_strings=True)
6952Database.synonym_keys = _database_gen_synonym_keys_iter
6953
6954# Modify Database to add a "metadata_keys()" method, instead of direct access
6955# to metadata_keys_begin and metadata_keys_end.
6956def _database_gen_metadata_keys_iter(self, prefix=""):
6957    """Get an iterator which returns all the metadata keys.
6958
6959    The iterator will return string objects.
6960
6961    If `prefix` is non-empty, only metadata keys with this prefix are returned.
6962
6963    """
6964    return TermIter(self._metadata_keys_begin(prefix),
6965                    self._metadata_keys_end(prefix),
6966                    return_strings=True)
6967Database.metadata_keys = _database_gen_metadata_keys_iter
6968
6969# Modify Document to add an "__iter__()" method and a "termlist()" method.
6970def _document_gen_termlist_iter(self):
6971    """Get an iterator over all the terms in a document.
6972
6973    The iterator will return TermListItem objects.
6974
6975    Access to term frequency and position information is only available until
6976    the iterator has moved on.
6977
6978    Note that term frequency information is only meaningful for a document
6979    retrieved from a database.  If term frequency information is requested for
6980    a document which was freshly created, an InvalidOperationError will be
6981    raised.
6982
6983    """
6984    # Note: document termlist iterators may be implemented entirely in-memory
6985    # (in which case access to all items could be allowed eagerly), but may
6986    # also be implemented by returning a database termlist (for documents which
6987    # are stored in a database, rather than freshly created).  We choose the
6988    # most conservative settings, to avoid doing eager access when lazy access
6989    # would be more appropriate.
6990    return TermIter(self.termlist_begin(), self.termlist_end(),
6991                    has_termfreq=TermIter.LAZY,
6992                    has_wdf=TermIter.EAGER,
6993                    has_positions=TermIter.LAZY)
6994Document.__iter__ = _document_gen_termlist_iter
6995Document.termlist = _document_gen_termlist_iter
6996
6997# Modify QueryParser to add a "stoplist()" method.
6998def _queryparser_gen_stoplist_iter(self):
6999    """Get an iterator over all the stopped terms from the previous query.
7000
7001    This returns an iterator over all the terms which were omitted from the
7002    previously parsed query due to being considered to be stopwords.  Each
7003    instance of a word omitted from the query is represented in the returned
7004    list, in the order in which the
7005
7006    The iterator will return string objects.
7007
7008    """
7009    return TermIter(self.stoplist_begin(), self.stoplist_end(),
7010                    return_strings=True)
7011QueryParser.stoplist = _queryparser_gen_stoplist_iter
7012
7013# Modify QueryParser to add an "unstemlist()" method.
7014def _queryparser_gen_unstemlist_iter(self, tname):
7015    """Get an iterator over all the unstemmed forms of a stemmed term.
7016
7017    This returns an iterator which returns all the unstemmed words which were
7018    stemmed to the stemmed form specified by `tname` when parsing the previous
7019    query.  Each instance of a word which stems to `tname` is returned by the
7020    iterator in the order in which the words appeared in the query - an
7021    individual unstemmed word may thus occur multiple times.
7022
7023    The iterator will return string objects.
7024
7025    """
7026    return TermIter(self.unstem_begin(tname), self.unstem_end(tname),
7027                    return_strings=True)
7028QueryParser.unstemlist = _queryparser_gen_unstemlist_iter
7029
7030# Modify ValueCountMatchSpy to add an "values()" method.
7031def wrapper():
7032    begin = ValueCountMatchSpy.values_begin
7033    del ValueCountMatchSpy.values_begin
7034    end = ValueCountMatchSpy.values_end
7035    del ValueCountMatchSpy.values_end
7036    def values_iter(self):
7037        """Get an iterator over all the values in the slot.
7038
7039        Values will be returned in ascending alphabetical order.
7040
7041        The iterator will return TermListItem objects: the value can be
7042        accessed as the `term` property, and the frequency can be accessed as
7043        the `termfreq` property.
7044
7045        """
7046        return TermIter(begin(self), end(self), has_termfreq=TermIter.EAGER)
7047    return values_iter
7048ValueCountMatchSpy.values = wrapper()
7049del wrapper
7050
7051# Modify ValueCountMatchSpy to add an "top_values()" method.
7052def wrapper():
7053    begin = ValueCountMatchSpy.top_values_begin
7054    del ValueCountMatchSpy.top_values_begin
7055    end = ValueCountMatchSpy.top_values_end
7056    del ValueCountMatchSpy.top_values_end
7057    def top_values_iter(self, maxvalues):
7058        """Get an iterator over the most frequent values for the slot.
7059
7060        Values will be returned in descending order of frequency.  Values with
7061        the same frequency will be returned in ascending alphabetical order.
7062
7063        The iterator will return TermListItem objects: the value can be
7064        accessed as the `term` property, and the frequency can be accessed as
7065        the `termfreq` property.
7066
7067        """
7068        return TermIter(begin(self, maxvalues), end(self, maxvalues),
7069                        has_termfreq=TermIter.EAGER)
7070    return top_values_iter
7071ValueCountMatchSpy.top_values = wrapper()
7072del wrapper
7073
7074# When we make a query, keep a note of postingsources involved, so they won't
7075# be deleted. This hack can probably be removed once xapian bug #186 is fixed.
7076__query_init_orig = Query.__init__
7077def _query_init(self, *args):
7078    """Make a new query object.
7079
7080    Many possible arguments are possible - see the documentation for details.
7081
7082    """
7083    ps = []
7084    if len(args) == 1 and isinstance(args[0], PostingSource):
7085        ps.append(args[0])
7086    else:
7087        for arg in args:
7088            if isinstance(arg, Query):
7089                ps.extend(getattr(arg, '_ps', []))
7090            elif hasattr(arg, '__iter__'):
7091                for listarg in arg:
7092                    if isinstance(listarg, Query):
7093                        ps.extend(getattr(listarg, '_ps', []))
7094    __query_init_orig(self, *args)
7095    self._ps = ps
7096Query.__init__ = _query_init
7097del _query_init
7098
7099# When setting a query on enquire, keep a note of postingsources involved, so
7100# they won't be deleted. This hack can probably be removed once xapian bug #186
7101# is fixed.
7102__enquire_set_query_orig = Enquire.set_query
7103def _enquire_set_query(self, query, qlen=0):
7104    self._ps = getattr(query, '_ps', [])
7105    return __enquire_set_query_orig(self, query, qlen)
7106_enquire_set_query.__doc__ = __enquire_set_query_orig.__doc__
7107Enquire.set_query = _enquire_set_query
7108del _enquire_set_query
7109
7110# When getting  a query from enquire, keep a note of postingsources involved,
7111# so they won't be deleted. This hack can probably be removed once xapian bug
7112# #186 is fixed.
7113__enquire_get_query_orig = Enquire.get_query
7114def _enquire_get_query(self):
7115    query = __enquire_get_query_orig(self)
7116    query._ps = getattr(self, '_ps', [])
7117    return query
7118_enquire_get_query.__doc__ = __enquire_get_query_orig.__doc__
7119Enquire.get_query = _enquire_get_query
7120del _enquire_get_query
7121
7122# When we set a ValueRangeProcessor into the QueryParser, keep a python
7123# reference so it won't be deleted. This hack can probably be removed once
7124# xapian bug #186 is fixed.
7125__queryparser_add_valuerangeprocessor_orig = QueryParser.add_valuerangeprocessor
7126def _queryparser_add_valuerangeprocessor(self, vrproc):
7127    if not hasattr(self, '_vrps'):
7128        self._vrps = []
7129    self._vrps.append(vrproc)
7130    return __queryparser_add_valuerangeprocessor_orig(self, vrproc)
7131_queryparser_add_valuerangeprocessor.__doc__ = __queryparser_add_valuerangeprocessor_orig.__doc__
7132QueryParser.add_valuerangeprocessor = _queryparser_add_valuerangeprocessor
7133del _queryparser_add_valuerangeprocessor
7134
7135# When we set a Stopper into the QueryParser, keep a python reference so it
7136# won't be deleted. This hack can probably be removed once xapian bug #186 is
7137# fixed.
7138__queryparser_set_stopper_orig = QueryParser.set_stopper
7139def _queryparser_set_stopper(self, stopper):
7140    self._stopper = stopper
7141    return __queryparser_set_stopper_orig(self, stopper)
7142_queryparser_set_stopper.__doc__ = __queryparser_set_stopper_orig.__doc__
7143QueryParser.set_stopper = _queryparser_set_stopper
7144del _queryparser_set_stopper
7145
7146# When we set a Stopper into the TermGenerator, keep a python reference so it
7147# won't be deleted. This hack can probably be removed once xapian bug #186 is
7148# fixed.
7149__termgenerator_set_stopper_orig = TermGenerator.set_stopper
7150def _termgenerator_set_stopper(self, stopper):
7151    self._stopper = stopper
7152    return __termgenerator_set_stopper_orig(self, stopper)
7153_termgenerator_set_stopper.__doc__ = __termgenerator_set_stopper_orig.__doc__
7154TermGenerator.set_stopper = _termgenerator_set_stopper
7155del _termgenerator_set_stopper
7156
7157def _enquire_check_deprec_args(reverse, kwargs, methodname):
7158    """Check the keyword arguments to one of the enquire set_sort_* methods.
7159
7160    """
7161    if reverse is not None:
7162        if 'ascending' in kwargs:
7163            raise TypeError('Only one of "reverse" and "ascending" may be specified')
7164        if len(kwargs) != 0:
7165            raise TypeError('Only keyword arguments allowed are "reverse" and "ascending"')
7166    else:
7167        import warnings
7168        if 'ascending' in kwargs:
7169            reverse = kwargs.get('ascending')
7170            del kwargs['ascending']
7171            warnings.warn("'ascending' as a parameter name to Enquire::" +
7172                          methodname + "() is deprecated and will be removed "
7173                          "in Xapian 1.3.0", DeprecationWarning)
7174        else:
7175            warnings.warn("Single argument form of Enquire::" +
7176                          methodname + "() is deprecated and will be removed "
7177                          "in Xapian 1.3.0", DeprecationWarning)
7178            reverse = True
7179        if len(kwargs) != 0:
7180            raise TypeError('Only keyword arguments allowed are "reverse" and "ascending"')
7181    return reverse
7182
7183# When we set a Sorter on enquire, keep a python reference so it won't be
7184# deleted.  This hack can probably be removed once xapian bug #186 is fixed.
7185__enquire_set_sort_by_key_orig = Enquire.set_sort_by_key
7186def _enquire_set_sort_by_key(self, sorter, reverse=None, **kwargs):
7187    self._sorter = sorter
7188    reverse = _enquire_check_deprec_args(reverse, kwargs, "set_sort_by_key")
7189    return __enquire_set_sort_by_key_orig(self, sorter, reverse)
7190_enquire_set_sort_by_key.__doc__ = __enquire_set_sort_by_key_orig.__doc__
7191Enquire.set_sort_by_key = _enquire_set_sort_by_key
7192del _enquire_set_sort_by_key
7193
7194__enquire_set_sort_by_key_then_relevance_orig = Enquire.set_sort_by_key_then_relevance
7195def _enquire_set_sort_by_key_then_relevance(self, sorter, reverse=None, **kwargs):
7196    self._sorter = sorter
7197    reverse = _enquire_check_deprec_args(reverse, kwargs, "set_sort_by_key_then_relevance")
7198    return __enquire_set_sort_by_key_then_relevance_orig(self, sorter, reverse)
7199_enquire_set_sort_by_key_then_relevance.__doc__ = __enquire_set_sort_by_key_then_relevance_orig.__doc__
7200Enquire.set_sort_by_key_then_relevance = _enquire_set_sort_by_key_then_relevance
7201del _enquire_set_sort_by_key_then_relevance
7202
7203__enquire_set_sort_by_relevance_then_key_orig = Enquire.set_sort_by_relevance_then_key
7204def _enquire_set_sort_by_relevance_then_key(self, sorter, reverse=None, **kwargs):
7205    self._sorter = sorter
7206    reverse = _enquire_check_deprec_args(reverse, kwargs, "set_sort_by_relevance_then_key")
7207    return __enquire_set_sort_by_relevance_then_key_orig(self, sorter, reverse)
7208_enquire_set_sort_by_relevance_then_key.__doc__ = __enquire_set_sort_by_relevance_then_key_orig.__doc__
7209Enquire.set_sort_by_relevance_then_key = _enquire_set_sort_by_relevance_then_key
7210del _enquire_set_sort_by_relevance_then_key
7211
7212# Add deprecation warnings about old argument names.  Can be removed in 1.3.0
7213__enquire_set_sort_by_value_orig = Enquire.set_sort_by_value
7214def _enquire_set_sort_by_value(self, sort_key, reverse=None, **kwargs):
7215    reverse = _enquire_check_deprec_args(reverse, kwargs, "set_sort_by_value")
7216    return __enquire_set_sort_by_value_orig(self, sort_key, reverse)
7217_enquire_set_sort_by_value.__doc__ = __enquire_set_sort_by_value_orig.__doc__
7218Enquire.set_sort_by_value = _enquire_set_sort_by_value
7219del _enquire_set_sort_by_value
7220
7221# Add deprecation warnings about old argument names.  Can be removed in 1.3.0
7222__enquire_set_sort_by_relevance_then_value_orig = Enquire.set_sort_by_relevance_then_value
7223def _enquire_set_sort_by_relevance_then_value(self, sort_key, reverse=None, **kwargs):
7224    reverse = _enquire_check_deprec_args(reverse, kwargs, "set_sort_by_relevance_then_value")
7225    return __enquire_set_sort_by_relevance_then_value_orig(self, sort_key, reverse)
7226_enquire_set_sort_by_relevance_then_value.__doc__ = __enquire_set_sort_by_relevance_then_value_orig.__doc__
7227Enquire.set_sort_by_relevance_then_value = _enquire_set_sort_by_relevance_then_value
7228del _enquire_set_sort_by_relevance_then_value
7229
7230# Add deprecation warnings about old argument names.  Can be removed in 1.3.0
7231__enquire_set_sort_by_value_then_relevance_orig = Enquire.set_sort_by_value_then_relevance
7232def _enquire_set_sort_by_value_then_relevance(self, sort_key, reverse=None, **kwargs):
7233    reverse = _enquire_check_deprec_args(reverse, kwargs, "set_sort_by_value_then_relevance")
7234    return __enquire_set_sort_by_value_then_relevance_orig(self, sort_key, reverse)
7235_enquire_set_sort_by_value_then_relevance.__doc__ = __enquire_set_sort_by_value_then_relevance_orig.__doc__
7236Enquire.set_sort_by_value_then_relevance = _enquire_set_sort_by_value_then_relevance
7237del _enquire_set_sort_by_value_then_relevance
7238
7239
7240##########################################
7241# Support for iteration of posting lists #
7242##########################################
7243
7244class PostingItem(object):
7245    """An item returned from iteration of a posting list.
7246
7247    The item supports access to the following attributes and properties:
7248
7249     - `docid`: The document ID corresponding to this PostingItem.
7250     - `doclength`: The length of the document corresponding to this
7251       PostingItem.
7252     - `wdf`: The within document frequency of the term which the posting list
7253       is for in the document corresponding to this PostingItem.
7254     - `positer`: An iterator over the positions which the term corresponing to
7255       this posting list occurs at in the document corresponding to this
7256       PostingItem.  This is only available until the iterator which returned
7257       this item next moves.
7258
7259    """
7260    __slots__ = ('_iter', 'docid', 'doclength', 'wdf',)
7261
7262    def __init__(self, iter):
7263        self._iter = iter
7264        self.docid = iter._iter.get_docid()
7265        self.doclength = iter._iter.get_doclength()
7266        self.wdf = iter._iter.get_wdf()
7267
7268        # Support for sequence API
7269        sequence = ['docid', 'doclength', 'wdf', 'positer']
7270        if not iter._has_positions:
7271            sequence[3] = PositionIter()
7272
7273    def _get_positer(self):
7274        """Get a position list iterator.
7275
7276        The iterator will return integers representing the positions that the
7277        term occurs at in the document corresponding to this PostingItem.
7278
7279        This will raise a InvalidOperationError exception if the iterator this
7280        item came from doesn't support position lists, or if the iterator has
7281        moved on since the item was returned from it.
7282
7283        """
7284        if not self._iter._has_positions:
7285            raise InvalidOperationError("Iterator does not support position lists")
7286        if self._iter._iter == self._iter._end or \
7287           self.docid != self._iter._iter.get_docid():
7288            raise InvalidOperationError("Iterator has moved, and does not support random access")
7289        return PositionIter(self._iter._iter.positionlist_begin(),
7290                            self._iter._iter.positionlist_end())
7291    positer = property(_get_positer, doc=
7292    """A position iterator for the current posting (if meaningful).
7293
7294    The iterator will return integers representing the positions that the term
7295    occurs at.
7296
7297    This will raise a InvalidOperationError exception if the iterator this item
7298    came from doesn't support position lists, or if the iterator has moved on
7299    since the item was returned from it.
7300
7301    """)
7302
7303
7304class PostingIter(object):
7305    """An iterator over a posting list.
7306
7307    The iterator will return PostingItem objects, which will be evaluated
7308    lazily where appropriate.
7309
7310    """
7311    __slots__ = ('_iter', '_end', '_has_positions', '_moved')
7312
7313    def __init__(self, start, end, has_positions=False):
7314        self._iter = start
7315        self._end = end
7316        self._has_positions = has_positions
7317
7318        # _moved is True if we've moved onto the next item.  This is needed so
7319        # that the iterator doesn't have to move on until just before next() is
7320        # called: since the iterator starts by pointing at a valid item, we
7321        # can't just call self._iter.next() unconditionally at the start of our
7322        # next() method.
7323        self._moved = True
7324
7325    def __iter__(self):
7326        return self
7327
7328    # For Python2:
7329    def next(self):
7330        if not self._moved:
7331            self._iter.next()
7332            self._moved = True
7333
7334        if self._iter == self._end:
7335            raise StopIteration
7336        else:
7337            self._moved = False
7338            return PostingItem(self)
7339
7340    # For Python3:
7341    def __next__(self):
7342        if not self._moved:
7343            next(self._iter)
7344            self._moved = True
7345
7346        if self._iter == self._end:
7347            raise StopIteration
7348        else:
7349            self._moved = False
7350            return PostingItem(self)
7351
7352    def skip_to(self, docid):
7353        """Skip the iterator forward.
7354
7355        The iterator is advanced to the first document with a document ID
7356        which is greater than or equal to the supplied document ID.
7357
7358        If there are no such items, this will raise StopIteration.
7359
7360        This returns the item which the iterator is moved to.  The subsequent
7361        item will be returned the next time that next() is called (unless
7362        skip_to() is called again first).
7363
7364        """
7365        if self._iter != self._end:
7366            self._iter.skip_to(docid)
7367        if self._iter == self._end:
7368            self._moved = True
7369            raise StopIteration
7370        self._moved = False
7371        return PostingItem(self)
7372
7373def _database_gen_postlist_iter(self, tname):
7374    """Get an iterator over the postings which are indexed by a given term.
7375
7376    If `tname` is empty, an iterator over all the documents will be returned
7377    (this will contain one entry for each document, will always return a wdf of
7378    1, and will not allow access to a position iterator).
7379
7380    """
7381    if len(tname) != 0:
7382        return PostingIter(self.postlist_begin(tname), self.postlist_end(tname),
7383                           has_positions=True)
7384    else:
7385        return PostingIter(self.postlist_begin(tname), self.postlist_end(tname))
7386Database.postlist = _database_gen_postlist_iter
7387
7388
7389###########################################
7390# Support for iteration of position lists #
7391###########################################
7392
7393class PositionIter(object):
7394    """An iterator over a position list.
7395
7396    The iterator will return integers, in ascending order.
7397
7398    """
7399    def __init__(self, start = 0, end = 0):
7400        self.iter = start
7401        self.end = end
7402
7403    def __iter__(self):
7404        return self
7405
7406    # For Python2:
7407    def next(self):
7408        if self.iter==self.end:
7409            raise StopIteration
7410        else:
7411            r = self.iter.get_termpos()
7412            self.iter.next()
7413            return r
7414
7415    # For Python3:
7416    def __next__(self):
7417        if self.iter==self.end:
7418            raise StopIteration
7419        else:
7420            r = self.iter.get_termpos()
7421            next(self.iter)
7422            return r
7423
7424# Modify Database to add a "positionlist()" method.
7425def _database_gen_positionlist_iter(self, docid, tname):
7426    """Get an iterator over all the positions in a given document of a term.
7427
7428    The iterator will return integers, in ascending order.
7429
7430    """
7431    return PositionIter(self.positionlist_begin(docid, tname), self.positionlist_end(docid, tname))
7432Database.positionlist = _database_gen_positionlist_iter
7433
7434########################################
7435# Support for iteration of value lists #
7436########################################
7437
7438class ValueItem(object):
7439    """An item returned from iteration of the values in a document.
7440
7441    The item supports access to the following attributes:
7442
7443     - `num`: The number of the value.
7444     - `value`: The contents of the value.
7445
7446    """
7447
7448    __slots__ = ('num', 'value', )
7449
7450    def __init__(self, num, value):
7451        self.num = num
7452        self.value = value
7453
7454class ValueIter(object):
7455    """An iterator over all the values stored in a document.
7456
7457    The iterator will return ValueItem objects, in ascending order of value number.
7458
7459    """
7460    def __init__(self, start, end):
7461        self.iter = start
7462        self.end = end
7463
7464    def __iter__(self):
7465        return self
7466
7467    # For Python2:
7468    def next(self):
7469        if self.iter==self.end:
7470            raise StopIteration
7471        else:
7472            r = ValueItem(self.iter.get_valueno(), self.iter.get_value())
7473            self.iter.next()
7474            return r
7475
7476    # For Python3:
7477    def __next__(self):
7478        if self.iter==self.end:
7479            raise StopIteration
7480        else:
7481            r = ValueItem(self.iter.get_valueno(), self.iter.get_value())
7482            next(self.iter)
7483            return r
7484
7485# Modify Document to add a "values()" method.
7486def _document_gen_values_iter(self):
7487    """Get an iterator over all the values stored in a document.
7488
7489    The iterator will return ValueItem objects, in ascending order of value number.
7490
7491    """
7492    return ValueIter(self.values_begin(), self.values_end())
7493Document.values = _document_gen_values_iter
7494
7495
7496##########################################
7497# Support for iteration of value streams #
7498##########################################
7499
7500class ValueStreamItem(object):
7501    """An item returned from iteration of the values in a document.
7502
7503    The item supports access to the following attributes:
7504
7505     - `docid`: The docid for the item.
7506     - `value`: The contents of the value.
7507
7508    """
7509
7510    __slots__ = ('docid', 'value', )
7511
7512    def __init__(self, docid, value):
7513        self.docid = docid
7514        self.value = value
7515
7516class ValueStreamIter(object):
7517    """An iterator over all the values stored in a document.
7518
7519    The iterator will return ValueStreamItem objects, in ascending order of value number.
7520
7521    """
7522    def __init__(self, start, end):
7523        self.iter = start
7524        self.end = end
7525        self.moved = True
7526
7527    def __iter__(self):
7528        return self
7529
7530    # For Python2:
7531    def next(self):
7532        if not self.moved:
7533            self.iter.next()
7534            self.moved = True
7535
7536        if self.iter==self.end:
7537            raise StopIteration
7538        else:
7539            self.moved = False
7540            return ValueStreamItem(self.iter.get_docid(), self.iter.get_value())
7541
7542    # For Python3:
7543    def __next__(self):
7544        if not self.moved:
7545            self.iter.next()
7546            self.moved = True
7547
7548        if self.iter==self.end:
7549            raise StopIteration
7550        else:
7551            self.moved = False
7552            return ValueStreamItem(self.iter.get_docid(), self.iter.get_value())
7553
7554    def skip_to(self, docid):
7555        """Skip the iterator forward.
7556
7557        The iterator is advanced to the first document with a document ID
7558        which is greater than or equal to the supplied document ID.
7559
7560        If there are no such items, this will raise StopIteration.
7561
7562        This returns the item which the iterator is moved to.  The subsequent
7563        item will be returned the next time that next() is called (unless
7564        skip_to() is called again first).
7565
7566        """
7567        if self.iter != self.end:
7568            self.iter.skip_to(docid)
7569        if self.iter == self.end:
7570            self.moved = True
7571            raise StopIteration
7572        self.moved = False
7573        return ValueStreamItem(self.iter.get_docid(), self.iter.get_value())
7574
7575# Modify Database to add a "valuestream()" method, and remove the
7576# valuestream_begin() and valuestream_end() methods.
7577def wrapper():
7578    vs_begin = Database.valuestream_begin
7579    vs_end = Database.valuestream_end
7580    def _database_gen_valuestream_iter(self, slot):
7581        """Get an iterator over all the values stored in a slot in the database.
7582
7583        The iterator will return ValueStreamItem objects, in ascending order of
7584        document id.
7585
7586        """
7587        return ValueStreamIter(vs_begin(self, slot), vs_end(self, slot))
7588    return _database_gen_valuestream_iter
7589Database.valuestream = wrapper()
7590del wrapper
7591del Database.valuestream_begin
7592del Database.valuestream_end
7593
7594# Fix up Enquire so that it keeps a python reference to the deciders supplied
7595# to it so that they won't be deleted before the Enquire object.  This hack can
7596# probably be removed once xapian bug #186 is fixed.
7597_enquire_add_matchspy_orig = Enquire.add_matchspy
7598def _enquire_match_spy_add(self, decider):
7599    if not hasattr(self, '_deciders'):
7600        self._deciders = []
7601    self._deciders.append(decider)
7602    _enquire_add_matchspy_orig(self, decider)
7603_enquire_match_spy_add.__doc__ = Enquire.add_matchspy.__doc__
7604Enquire.add_matchspy = _enquire_match_spy_add
7605
7606_enquire_clear_matchspies_orig = Enquire.clear_matchspies
7607def _enquire_match_spies_clear(self):
7608    _enquire_clear_matchspies_orig(self)
7609    if hasattr(self, '_deciders'):
7610        del self._deciders
7611_enquire_match_spies_clear.__doc__ = Enquire.clear_matchspies.__doc__
7612Enquire.clear_matchspies = _enquire_match_spies_clear
7613
7614
7615# Fix up Stem.__init__() so that it calls __disown__() on the passed
7616# StemImplementation object so that Python won't delete it from under us.
7617_stem_init_orig = Stem.__init__
7618def _stem_init(self, *args):
7619    _stem_init_orig(self, *args)
7620    if len(args) > 0 and isinstance(args[0], StemImplementation):
7621        args[0].__disown__()
7622_stem_init.__doc__ = Stem.__init__.__doc__
7623Stem.__init__ = _stem_init
7624
7625
7626# Remove static methods which shouldn't be in the API.
7627del Document_unserialise
7628del Query_unserialise
7629
7630# Add wrappers for Query::MatchAll and Query::MatchNothing
7631Query.MatchAll = Query("")
7632Query.MatchNothing = Query()
7633
7634# Require to support the non-pythonic iterators for Python 3 - these can be
7635# removed once support for the non-pythonic iterators is dropped in 1.3.0.
7636ESetIterator.__next__ = lambda self: ESetIterator.next(self)
7637MSetIterator.__next__ = lambda self: MSetIterator.next(self)
7638PostingIterator.__next__ = lambda self: PostingIterator.next(self)
7639PositionIterator.__next__ = lambda self: PositionIterator.next(self)
7640TermIterator.__next__ = lambda self: TermIterator.next(self)
7641ValueIterator.__next__ = lambda self: ValueIterator.next(self)
7642
7643
7644# Set the list of names which should be public.
7645# Note that this needs to happen at the end of xapian.py.
7646__all__ = []
7647for item in dir():
7648    if item.startswith('_') or item.endswith('_swigregister') or item.endswith('Iterator'):
7649        continue
7650    __all__.append(item)
7651__all__ = tuple(__all__)
7652
7653
7654
7655