1# This file was automatically generated by SWIG (http://www.swig.org).
2# Version 3.0.13
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"""
9Xapian is a highly adaptable toolkit which allows developers to easily
10add advanced indexing and search facilities to their own applications.
11It has built-in support for several families of weighting models
12and also supports a rich set of boolean query operators.
13
14In addition to the doc strings provided by this python library, you
15may wish to look at the library's overall documentation, either
16installed along with the bindings or online at
17<https://xapian.org/docs/bindings/python/>, as well as the library's
18documentation, possibly installed with the library or with its
19development files, or again online at <https://xapian.org/docs/>.
20"""
21
22
23
24from . import _xapian
25
26def _swig_setattr(self, class_type, name, value):
27    if (name == "thisown"):
28        return self.this.own(value)
29    if (name == "this"):
30        if type(value).__name__ == 'SwigPyObject':
31            self.__dict__[name] = value
32            return
33    method = class_type.__swig_setmethods__.get(name, None)
34    if method:
35        return method(self, value)
36    object.__setattr__(self, name, value)
37
38
39
40
41def _swig_getattr(self, class_type, name):
42    if (name == "thisown"):
43        return self.this.own()
44    method = class_type.__swig_getmethods__.get(name, None)
45    if method:
46        return method(self)
47    raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
48
49
50def _swig_repr(self):
51    strthis = ""
52    if hasattr(self.this, '__repr__'):
53        strthis = "proxy of " + self.this.__repr__()
54
55    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
56
57
58
59from weakref import proxy as weakref_proxy
60
61
62
63__version__ = '1.4.18'
64
65class SwigPyIterator(object):
66    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
67
68    def __init__(self, *args, **kwargs):
69        raise AttributeError("No constructor defined - class is abstract")
70    __repr__ = _swig_repr
71    __swig_destroy__ = _xapian.delete_SwigPyIterator
72    def __iter__(self):
73        return self
74SwigPyIterator.value = _xapian.SWIG_PyInstanceMethod_New(_xapian.SwigPyIterator_value)
75SwigPyIterator.incr = _xapian.SWIG_PyInstanceMethod_New(_xapian.SwigPyIterator_incr)
76SwigPyIterator.decr = _xapian.SWIG_PyInstanceMethod_New(_xapian.SwigPyIterator_decr)
77SwigPyIterator.distance = _xapian.SWIG_PyInstanceMethod_New(_xapian.SwigPyIterator_distance)
78SwigPyIterator.equal = _xapian.SWIG_PyInstanceMethod_New(_xapian.SwigPyIterator_equal)
79SwigPyIterator.copy = _xapian.SWIG_PyInstanceMethod_New(_xapian.SwigPyIterator_copy)
80SwigPyIterator.next = _xapian.SWIG_PyInstanceMethod_New(_xapian.SwigPyIterator_next)
81SwigPyIterator.__next__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.SwigPyIterator___next__)
82SwigPyIterator.previous = _xapian.SWIG_PyInstanceMethod_New(_xapian.SwigPyIterator_previous)
83SwigPyIterator.advance = _xapian.SWIG_PyInstanceMethod_New(_xapian.SwigPyIterator_advance)
84SwigPyIterator.__eq__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.SwigPyIterator___eq__)
85SwigPyIterator.__ne__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.SwigPyIterator___ne__)
86SwigPyIterator.__iadd__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.SwigPyIterator___iadd__)
87SwigPyIterator.__isub__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.SwigPyIterator___isub__)
88SwigPyIterator.__add__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.SwigPyIterator___add__)
89SwigPyIterator.__sub__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.SwigPyIterator___sub__)
90SwigPyIterator_swigregister = _xapian.SwigPyIterator_swigregister
91SwigPyIterator_swigregister(SwigPyIterator)
92
93class Error(Exception):
94    """
95
96
97    All exceptions thrown by Xapian are subclasses of Xapian::Error.
98
99    This class can not be instantiated directly - instead a subclass
100    should be used.
101    """
102
103    __swig_setmethods__ = {}
104    __setattr__ = lambda self, name, value: _swig_setattr(self, Error, name, value)
105    __swig_getmethods__ = {}
106    __getattr__ = lambda self, name: _swig_getattr(self, Error, name)
107
108    def __init__(self, *args, **kwargs):
109        raise AttributeError("No constructor defined")
110    __repr__ = _swig_repr
111
112    def get_type(self):
113        """
114
115
116        The type of this error (e.g. "DocNotFoundError".)
117
118        const char* Xapian::Error::get_type() const
119        """
120        return _xapian.Error_get_type(self)
121
122
123    def get_msg(self):
124        """
125
126
127        Message giving details of the error, intended for human consumption.
128
129        const std::string& Xapian::Error::get_msg() const
130        """
131        return _xapian.Error_get_msg(self)
132
133
134    def get_context(self):
135        """
136
137
138        Optional context information.
139
140        const std::string& Xapian::Error::get_context() const
141
142        This context is intended for use by Xapian::ErrorHandler (for example
143        so it can know which remote server is unreliable and report the
144        problem and remove that server from those being searched). But it's
145        typically a plain-text string, and so also fit for human consumption.
146
147        """
148        return _xapian.Error_get_context(self)
149
150
151    def get_error_string(self):
152        """
153
154
155        Returns any system error string associated with this exception.
156
157        const char* Xapian::Error::get_error_string() const
158
159        The system error string may come from errno, h_errno (on UNIX), or
160        GetLastError() (on MS Windows). If there is no associated system error
161        string, NULL is returned.
162        """
163        return _xapian.Error_get_error_string(self)
164
165    __swig_destroy__ = _xapian.delete_Error
166Error.get_type = _xapian.SWIG_PyInstanceMethod_New(_xapian.Error_get_type)
167Error.get_msg = _xapian.SWIG_PyInstanceMethod_New(_xapian.Error_get_msg)
168Error.get_context = _xapian.SWIG_PyInstanceMethod_New(_xapian.Error_get_context)
169Error.get_error_string = _xapian.SWIG_PyInstanceMethod_New(_xapian.Error_get_error_string)
170Error.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.Error___str__)
171Error_swigregister = _xapian.Error_swigregister
172Error_swigregister(Error)
173
174class LogicError(Error):
175    """
176
177
178    The base class for exceptions indicating errors in the program logic.
179
180    A subclass of LogicError will be thrown if Xapian detects a violation
181    of a class invariant or a logical precondition or postcondition, etc.
182
183    """
184
185    __swig_setmethods__ = {}
186    for _s in [Error]:
187        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
188    __setattr__ = lambda self, name, value: _swig_setattr(self, LogicError, name, value)
189    __swig_getmethods__ = {}
190    for _s in [Error]:
191        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
192    __getattr__ = lambda self, name: _swig_getattr(self, LogicError, name)
193
194    def __init__(self, *args, **kwargs):
195        raise AttributeError("No constructor defined")
196    __repr__ = _swig_repr
197    __swig_destroy__ = _xapian.delete_LogicError
198LogicError_swigregister = _xapian.LogicError_swigregister
199LogicError_swigregister(LogicError)
200
201class RuntimeError(Error):
202    """
203
204
205    The base class for exceptions indicating errors only detectable at
206    runtime.
207
208    A subclass of RuntimeError will be thrown if Xapian detects an error
209    which is exception derived from RuntimeError is thrown when an error
210    is caused by problems with the data or environment rather than a
211    programming mistake.
212    """
213
214    __swig_setmethods__ = {}
215    for _s in [Error]:
216        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
217    __setattr__ = lambda self, name, value: _swig_setattr(self, RuntimeError, name, value)
218    __swig_getmethods__ = {}
219    for _s in [Error]:
220        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
221    __getattr__ = lambda self, name: _swig_getattr(self, RuntimeError, name)
222
223    def __init__(self, *args, **kwargs):
224        raise AttributeError("No constructor defined")
225    __repr__ = _swig_repr
226    __swig_destroy__ = _xapian.delete_RuntimeError
227RuntimeError_swigregister = _xapian.RuntimeError_swigregister
228RuntimeError_swigregister(RuntimeError)
229
230class AssertionError(LogicError):
231    """
232
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
243    __swig_setmethods__ = {}
244    for _s in [LogicError]:
245        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
246    __setattr__ = lambda self, name, value: _swig_setattr(self, AssertionError, name, value)
247    __swig_getmethods__ = {}
248    for _s in [LogicError]:
249        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
250    __getattr__ = lambda self, name: _swig_getattr(self, AssertionError, name)
251    __repr__ = _swig_repr
252
253    def __init__(self, *args):
254        """
255
256
257        Construct from message and errno value.
258
259        Xapian::AssertionError::AssertionError(const std::string &msg_, int
260        errno_)
261
262        Parameters:
263        -----------
264
265        msg_:  Message giving details of the error, intended for human
266        consumption.
267
268        errno_:  Optional errno value associated with this error.
269        """
270        _xapian.AssertionError_swiginit(self, _xapian.new_AssertionError(*args))
271    __swig_destroy__ = _xapian.delete_AssertionError
272AssertionError_swigregister = _xapian.AssertionError_swigregister
273AssertionError_swigregister(AssertionError)
274
275class InvalidArgumentError(LogicError):
276    """
277
278
279    InvalidArgumentError indicates an invalid parameter value was passed
280    to the API.
281    """
282
283    __swig_setmethods__ = {}
284    for _s in [LogicError]:
285        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
286    __setattr__ = lambda self, name, value: _swig_setattr(self, InvalidArgumentError, name, value)
287    __swig_getmethods__ = {}
288    for _s in [LogicError]:
289        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
290    __getattr__ = lambda self, name: _swig_getattr(self, InvalidArgumentError, name)
291    __repr__ = _swig_repr
292
293    def __init__(self, *args):
294        """
295
296
297        Construct from message and errno value.
298
299        Xapian::InvalidArgumentError::InvalidArgumentError(const std::string
300        &msg_, int errno_)
301
302        Parameters:
303        -----------
304
305        msg_:  Message giving details of the error, intended for human
306        consumption.
307
308        errno_:  Optional errno value associated with this error.
309        """
310        _xapian.InvalidArgumentError_swiginit(self, _xapian.new_InvalidArgumentError(*args))
311    __swig_destroy__ = _xapian.delete_InvalidArgumentError
312InvalidArgumentError_swigregister = _xapian.InvalidArgumentError_swigregister
313InvalidArgumentError_swigregister(InvalidArgumentError)
314
315class InvalidOperationError(LogicError):
316    """
317
318
319    InvalidOperationError indicates the API was used in an invalid way.
320    """
321
322    __swig_setmethods__ = {}
323    for _s in [LogicError]:
324        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
325    __setattr__ = lambda self, name, value: _swig_setattr(self, InvalidOperationError, name, value)
326    __swig_getmethods__ = {}
327    for _s in [LogicError]:
328        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
329    __getattr__ = lambda self, name: _swig_getattr(self, InvalidOperationError, name)
330    __repr__ = _swig_repr
331
332    def __init__(self, *args):
333        """
334
335
336        Construct from message and errno value.
337
338        Xapian::InvalidOperationError::InvalidOperationError(const std::string
339        &msg_, int errno_)
340
341        Parameters:
342        -----------
343
344        msg_:  Message giving details of the error, intended for human
345        consumption.
346
347        errno_:  Optional errno value associated with this error.
348        """
349        _xapian.InvalidOperationError_swiginit(self, _xapian.new_InvalidOperationError(*args))
350    __swig_destroy__ = _xapian.delete_InvalidOperationError
351InvalidOperationError_swigregister = _xapian.InvalidOperationError_swigregister
352InvalidOperationError_swigregister(InvalidOperationError)
353
354class UnimplementedError(LogicError):
355    """
356
357
358    UnimplementedError indicates an attempt to use an unimplemented
359    feature.
360    """
361
362    __swig_setmethods__ = {}
363    for _s in [LogicError]:
364        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
365    __setattr__ = lambda self, name, value: _swig_setattr(self, UnimplementedError, name, value)
366    __swig_getmethods__ = {}
367    for _s in [LogicError]:
368        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
369    __getattr__ = lambda self, name: _swig_getattr(self, UnimplementedError, name)
370    __repr__ = _swig_repr
371
372    def __init__(self, *args):
373        """
374
375
376        Construct from message and errno value.
377
378        Xapian::UnimplementedError::UnimplementedError(const std::string
379        &msg_, int errno_)
380
381        Parameters:
382        -----------
383
384        msg_:  Message giving details of the error, intended for human
385        consumption.
386
387        errno_:  Optional errno value associated with this error.
388        """
389        _xapian.UnimplementedError_swiginit(self, _xapian.new_UnimplementedError(*args))
390    __swig_destroy__ = _xapian.delete_UnimplementedError
391UnimplementedError_swigregister = _xapian.UnimplementedError_swigregister
392UnimplementedError_swigregister(UnimplementedError)
393
394class DatabaseError(RuntimeError):
395    """
396
397
398    DatabaseError indicates some sort of database related error.
399    """
400
401    __swig_setmethods__ = {}
402    for _s in [RuntimeError]:
403        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
404    __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseError, name, value)
405    __swig_getmethods__ = {}
406    for _s in [RuntimeError]:
407        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
408    __getattr__ = lambda self, name: _swig_getattr(self, DatabaseError, name)
409    __repr__ = _swig_repr
410
411    def __init__(self, *args):
412        """
413
414
415        Construct from message and errno value.
416
417        Xapian::DatabaseError::DatabaseError(const std::string &msg_, int
418        errno_)
419
420        Parameters:
421        -----------
422
423        msg_:  Message giving details of the error, intended for human
424        consumption.
425
426        errno_:  Optional errno value associated with this error.
427        """
428        _xapian.DatabaseError_swiginit(self, _xapian.new_DatabaseError(*args))
429    __swig_destroy__ = _xapian.delete_DatabaseError
430DatabaseError_swigregister = _xapian.DatabaseError_swigregister
431DatabaseError_swigregister(DatabaseError)
432
433class DatabaseCorruptError(DatabaseError):
434    """
435
436
437    DatabaseCorruptError indicates database corruption was detected.
438    """
439
440    __swig_setmethods__ = {}
441    for _s in [DatabaseError]:
442        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
443    __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseCorruptError, name, value)
444    __swig_getmethods__ = {}
445    for _s in [DatabaseError]:
446        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
447    __getattr__ = lambda self, name: _swig_getattr(self, DatabaseCorruptError, name)
448    __repr__ = _swig_repr
449
450    def __init__(self, *args):
451        """
452
453
454        Construct from message and errno value.
455
456        Xapian::DatabaseCorruptError::DatabaseCorruptError(const std::string
457        &msg_, int errno_)
458
459        Parameters:
460        -----------
461
462        msg_:  Message giving details of the error, intended for human
463        consumption.
464
465        errno_:  Optional errno value associated with this error.
466        """
467        _xapian.DatabaseCorruptError_swiginit(self, _xapian.new_DatabaseCorruptError(*args))
468    __swig_destroy__ = _xapian.delete_DatabaseCorruptError
469DatabaseCorruptError_swigregister = _xapian.DatabaseCorruptError_swigregister
470DatabaseCorruptError_swigregister(DatabaseCorruptError)
471
472class DatabaseCreateError(DatabaseError):
473    """
474
475
476    DatabaseCreateError indicates a failure to create a database.
477    """
478
479    __swig_setmethods__ = {}
480    for _s in [DatabaseError]:
481        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
482    __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseCreateError, name, value)
483    __swig_getmethods__ = {}
484    for _s in [DatabaseError]:
485        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
486    __getattr__ = lambda self, name: _swig_getattr(self, DatabaseCreateError, name)
487    __repr__ = _swig_repr
488
489    def __init__(self, *args):
490        """
491
492
493        Construct from message and errno value.
494
495        Xapian::DatabaseCreateError::DatabaseCreateError(const std::string
496        &msg_, int errno_)
497
498        Parameters:
499        -----------
500
501        msg_:  Message giving details of the error, intended for human
502        consumption.
503
504        errno_:  Optional errno value associated with this error.
505        """
506        _xapian.DatabaseCreateError_swiginit(self, _xapian.new_DatabaseCreateError(*args))
507    __swig_destroy__ = _xapian.delete_DatabaseCreateError
508DatabaseCreateError_swigregister = _xapian.DatabaseCreateError_swigregister
509DatabaseCreateError_swigregister(DatabaseCreateError)
510
511class DatabaseLockError(DatabaseError):
512    """
513
514
515    DatabaseLockError indicates failure to lock a database.
516    """
517
518    __swig_setmethods__ = {}
519    for _s in [DatabaseError]:
520        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
521    __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseLockError, name, value)
522    __swig_getmethods__ = {}
523    for _s in [DatabaseError]:
524        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
525    __getattr__ = lambda self, name: _swig_getattr(self, DatabaseLockError, name)
526    __repr__ = _swig_repr
527
528    def __init__(self, *args):
529        """
530
531
532        Construct from message and errno value.
533
534        Xapian::DatabaseLockError::DatabaseLockError(const std::string &msg_,
535        int errno_)
536
537        Parameters:
538        -----------
539
540        msg_:  Message giving details of the error, intended for human
541        consumption.
542
543        errno_:  Optional errno value associated with this error.
544        """
545        _xapian.DatabaseLockError_swiginit(self, _xapian.new_DatabaseLockError(*args))
546    __swig_destroy__ = _xapian.delete_DatabaseLockError
547DatabaseLockError_swigregister = _xapian.DatabaseLockError_swigregister
548DatabaseLockError_swigregister(DatabaseLockError)
549
550class DatabaseModifiedError(DatabaseError):
551    """
552
553
554    DatabaseModifiedError indicates a database was modified.
555
556    To recover after catching this error, you need to call
557    Xapian::Database::reopen() on the Database and repeat the operation
558    which failed.
559    """
560
561    __swig_setmethods__ = {}
562    for _s in [DatabaseError]:
563        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
564    __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseModifiedError, name, value)
565    __swig_getmethods__ = {}
566    for _s in [DatabaseError]:
567        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
568    __getattr__ = lambda self, name: _swig_getattr(self, DatabaseModifiedError, name)
569    __repr__ = _swig_repr
570
571    def __init__(self, *args):
572        """
573
574
575        Construct from message and errno value.
576
577        Xapian::DatabaseModifiedError::DatabaseModifiedError(const std::string
578        &msg_, int errno_)
579
580        Parameters:
581        -----------
582
583        msg_:  Message giving details of the error, intended for human
584        consumption.
585
586        errno_:  Optional errno value associated with this error.
587        """
588        _xapian.DatabaseModifiedError_swiginit(self, _xapian.new_DatabaseModifiedError(*args))
589    __swig_destroy__ = _xapian.delete_DatabaseModifiedError
590DatabaseModifiedError_swigregister = _xapian.DatabaseModifiedError_swigregister
591DatabaseModifiedError_swigregister(DatabaseModifiedError)
592
593class DatabaseOpeningError(DatabaseError):
594    """
595
596
597    DatabaseOpeningError indicates failure to open a database.
598    """
599
600    __swig_setmethods__ = {}
601    for _s in [DatabaseError]:
602        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
603    __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseOpeningError, name, value)
604    __swig_getmethods__ = {}
605    for _s in [DatabaseError]:
606        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
607    __getattr__ = lambda self, name: _swig_getattr(self, DatabaseOpeningError, name)
608    __repr__ = _swig_repr
609
610    def __init__(self, *args):
611        """
612
613
614        Construct from message and errno value.
615
616        Xapian::DatabaseOpeningError::DatabaseOpeningError(const std::string
617        &msg_, int errno_)
618
619        Parameters:
620        -----------
621
622        msg_:  Message giving details of the error, intended for human
623        consumption.
624
625        errno_:  Optional errno value associated with this error.
626        """
627        _xapian.DatabaseOpeningError_swiginit(self, _xapian.new_DatabaseOpeningError(*args))
628    __swig_destroy__ = _xapian.delete_DatabaseOpeningError
629DatabaseOpeningError_swigregister = _xapian.DatabaseOpeningError_swigregister
630DatabaseOpeningError_swigregister(DatabaseOpeningError)
631
632class DatabaseVersionError(DatabaseOpeningError):
633    """
634
635
636    DatabaseVersionError indicates that a database is in an unsupported
637    format.
638
639    From time to time, new versions of Xapian will require the database
640    format to be changed, to allow new information to be stored or new
641    optimisations to be performed. Backwards compatibility will sometimes
642    be maintained, so that new versions of Xapian can open old databases,
643    but in some cases Xapian will be unable to open a database because it
644    is in too old (or new) a format. This can be resolved either be
645    upgrading or downgrading the version of Xapian in use, or by
646    rebuilding the database from scratch with the current version of
647    Xapian.
648    """
649
650    __swig_setmethods__ = {}
651    for _s in [DatabaseOpeningError]:
652        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
653    __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseVersionError, name, value)
654    __swig_getmethods__ = {}
655    for _s in [DatabaseOpeningError]:
656        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
657    __getattr__ = lambda self, name: _swig_getattr(self, DatabaseVersionError, name)
658    __repr__ = _swig_repr
659
660    def __init__(self, *args):
661        """
662
663
664        Construct from message and errno value.
665
666        Xapian::DatabaseVersionError::DatabaseVersionError(const std::string
667        &msg_, int errno_)
668
669        Parameters:
670        -----------
671
672        msg_:  Message giving details of the error, intended for human
673        consumption.
674
675        errno_:  Optional errno value associated with this error.
676        """
677        _xapian.DatabaseVersionError_swiginit(self, _xapian.new_DatabaseVersionError(*args))
678    __swig_destroy__ = _xapian.delete_DatabaseVersionError
679DatabaseVersionError_swigregister = _xapian.DatabaseVersionError_swigregister
680DatabaseVersionError_swigregister(DatabaseVersionError)
681
682class DocNotFoundError(RuntimeError):
683    """
684
685
686    Indicates an attempt to access a document not present in the database.
687
688    """
689
690    __swig_setmethods__ = {}
691    for _s in [RuntimeError]:
692        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
693    __setattr__ = lambda self, name, value: _swig_setattr(self, DocNotFoundError, name, value)
694    __swig_getmethods__ = {}
695    for _s in [RuntimeError]:
696        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
697    __getattr__ = lambda self, name: _swig_getattr(self, DocNotFoundError, name)
698    __repr__ = _swig_repr
699
700    def __init__(self, *args):
701        """
702
703
704        Construct from message and errno value.
705
706        Xapian::DocNotFoundError::DocNotFoundError(const std::string &msg_,
707        int errno_)
708
709        Parameters:
710        -----------
711
712        msg_:  Message giving details of the error, intended for human
713        consumption.
714
715        errno_:  Optional errno value associated with this error.
716        """
717        _xapian.DocNotFoundError_swiginit(self, _xapian.new_DocNotFoundError(*args))
718    __swig_destroy__ = _xapian.delete_DocNotFoundError
719DocNotFoundError_swigregister = _xapian.DocNotFoundError_swigregister
720DocNotFoundError_swigregister(DocNotFoundError)
721
722class FeatureUnavailableError(RuntimeError):
723    """
724
725
726    Indicates an attempt to use a feature which is unavailable.
727
728    Typically a feature is unavailable because it wasn't compiled in, or
729    because it requires other software or facilities which aren't
730    available.
731    """
732
733    __swig_setmethods__ = {}
734    for _s in [RuntimeError]:
735        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
736    __setattr__ = lambda self, name, value: _swig_setattr(self, FeatureUnavailableError, name, value)
737    __swig_getmethods__ = {}
738    for _s in [RuntimeError]:
739        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
740    __getattr__ = lambda self, name: _swig_getattr(self, FeatureUnavailableError, name)
741    __repr__ = _swig_repr
742
743    def __init__(self, *args):
744        """
745
746
747        Construct from message and errno value.
748
749        Xapian::FeatureUnavailableError::FeatureUnavailableError(const
750        std::string &msg_, int errno_)
751
752        Parameters:
753        -----------
754
755        msg_:  Message giving details of the error, intended for human
756        consumption.
757
758        errno_:  Optional errno value associated with this error.
759        """
760        _xapian.FeatureUnavailableError_swiginit(self, _xapian.new_FeatureUnavailableError(*args))
761    __swig_destroy__ = _xapian.delete_FeatureUnavailableError
762FeatureUnavailableError_swigregister = _xapian.FeatureUnavailableError_swigregister
763FeatureUnavailableError_swigregister(FeatureUnavailableError)
764
765class InternalError(RuntimeError):
766    """
767
768
769    InternalError indicates a runtime problem of some sort.
770    """
771
772    __swig_setmethods__ = {}
773    for _s in [RuntimeError]:
774        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
775    __setattr__ = lambda self, name, value: _swig_setattr(self, InternalError, name, value)
776    __swig_getmethods__ = {}
777    for _s in [RuntimeError]:
778        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
779    __getattr__ = lambda self, name: _swig_getattr(self, InternalError, name)
780    __repr__ = _swig_repr
781
782    def __init__(self, *args):
783        """
784
785
786        Construct from message and errno value.
787
788        Xapian::InternalError::InternalError(const std::string &msg_, int
789        errno_)
790
791        Parameters:
792        -----------
793
794        msg_:  Message giving details of the error, intended for human
795        consumption.
796
797        errno_:  Optional errno value associated with this error.
798        """
799        _xapian.InternalError_swiginit(self, _xapian.new_InternalError(*args))
800    __swig_destroy__ = _xapian.delete_InternalError
801InternalError_swigregister = _xapian.InternalError_swigregister
802InternalError_swigregister(InternalError)
803
804class NetworkError(RuntimeError):
805    """
806
807
808    Indicates a problem communicating with a remote database.
809    """
810
811    __swig_setmethods__ = {}
812    for _s in [RuntimeError]:
813        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
814    __setattr__ = lambda self, name, value: _swig_setattr(self, NetworkError, name, value)
815    __swig_getmethods__ = {}
816    for _s in [RuntimeError]:
817        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
818    __getattr__ = lambda self, name: _swig_getattr(self, NetworkError, name)
819    __repr__ = _swig_repr
820
821    def __init__(self, *args):
822        """
823
824
825        Construct from message and errno value.
826
827        Xapian::NetworkError::NetworkError(const std::string &msg_, int
828        errno_)
829
830        Parameters:
831        -----------
832
833        msg_:  Message giving details of the error, intended for human
834        consumption.
835
836        errno_:  Optional errno value associated with this error.
837        """
838        _xapian.NetworkError_swiginit(self, _xapian.new_NetworkError(*args))
839    __swig_destroy__ = _xapian.delete_NetworkError
840NetworkError_swigregister = _xapian.NetworkError_swigregister
841NetworkError_swigregister(NetworkError)
842
843class NetworkTimeoutError(NetworkError):
844    """
845
846
847    Indicates a timeout expired while communicating with a remote
848    database.
849    """
850
851    __swig_setmethods__ = {}
852    for _s in [NetworkError]:
853        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
854    __setattr__ = lambda self, name, value: _swig_setattr(self, NetworkTimeoutError, name, value)
855    __swig_getmethods__ = {}
856    for _s in [NetworkError]:
857        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
858    __getattr__ = lambda self, name: _swig_getattr(self, NetworkTimeoutError, name)
859    __repr__ = _swig_repr
860
861    def __init__(self, *args):
862        """
863
864
865        Construct from message and errno value.
866
867        Xapian::NetworkTimeoutError::NetworkTimeoutError(const std::string
868        &msg_, int errno_)
869
870        Parameters:
871        -----------
872
873        msg_:  Message giving details of the error, intended for human
874        consumption.
875
876        errno_:  Optional errno value associated with this error.
877        """
878        _xapian.NetworkTimeoutError_swiginit(self, _xapian.new_NetworkTimeoutError(*args))
879    __swig_destroy__ = _xapian.delete_NetworkTimeoutError
880NetworkTimeoutError_swigregister = _xapian.NetworkTimeoutError_swigregister
881NetworkTimeoutError_swigregister(NetworkTimeoutError)
882
883class QueryParserError(RuntimeError):
884    """
885
886
887    Indicates a query string can't be parsed.
888    """
889
890    __swig_setmethods__ = {}
891    for _s in [RuntimeError]:
892        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
893    __setattr__ = lambda self, name, value: _swig_setattr(self, QueryParserError, name, value)
894    __swig_getmethods__ = {}
895    for _s in [RuntimeError]:
896        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
897    __getattr__ = lambda self, name: _swig_getattr(self, QueryParserError, name)
898    __repr__ = _swig_repr
899
900    def __init__(self, *args):
901        """
902
903
904        Construct from message and errno value.
905
906        Xapian::QueryParserError::QueryParserError(const std::string &msg_,
907        int errno_)
908
909        Parameters:
910        -----------
911
912        msg_:  Message giving details of the error, intended for human
913        consumption.
914
915        errno_:  Optional errno value associated with this error.
916        """
917        _xapian.QueryParserError_swiginit(self, _xapian.new_QueryParserError(*args))
918    __swig_destroy__ = _xapian.delete_QueryParserError
919QueryParserError_swigregister = _xapian.QueryParserError_swigregister
920QueryParserError_swigregister(QueryParserError)
921
922class SerialisationError(RuntimeError):
923    """
924
925
926    Indicates an error in the std::string serialisation of an object.
927    """
928
929    __swig_setmethods__ = {}
930    for _s in [RuntimeError]:
931        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
932    __setattr__ = lambda self, name, value: _swig_setattr(self, SerialisationError, name, value)
933    __swig_getmethods__ = {}
934    for _s in [RuntimeError]:
935        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
936    __getattr__ = lambda self, name: _swig_getattr(self, SerialisationError, name)
937    __repr__ = _swig_repr
938
939    def __init__(self, *args):
940        """
941
942
943        Construct from message and errno value.
944
945        Xapian::SerialisationError::SerialisationError(const std::string
946        &msg_, int errno_)
947
948        Parameters:
949        -----------
950
951        msg_:  Message giving details of the error, intended for human
952        consumption.
953
954        errno_:  Optional errno value associated with this error.
955        """
956        _xapian.SerialisationError_swiginit(self, _xapian.new_SerialisationError(*args))
957    __swig_destroy__ = _xapian.delete_SerialisationError
958SerialisationError_swigregister = _xapian.SerialisationError_swigregister
959SerialisationError_swigregister(SerialisationError)
960
961class RangeError(RuntimeError):
962    """
963
964
965    RangeError indicates an attempt to access outside the bounds of a
966    container.
967    """
968
969    __swig_setmethods__ = {}
970    for _s in [RuntimeError]:
971        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
972    __setattr__ = lambda self, name, value: _swig_setattr(self, RangeError, name, value)
973    __swig_getmethods__ = {}
974    for _s in [RuntimeError]:
975        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
976    __getattr__ = lambda self, name: _swig_getattr(self, RangeError, name)
977    __repr__ = _swig_repr
978
979    def __init__(self, *args):
980        """
981
982
983        Construct from message and errno value.
984
985        Xapian::RangeError::RangeError(const std::string &msg_, int errno_)
986
987        Parameters:
988        -----------
989
990        msg_:  Message giving details of the error, intended for human
991        consumption.
992
993        errno_:  Optional errno value associated with this error.
994        """
995        _xapian.RangeError_swiginit(self, _xapian.new_RangeError(*args))
996    __swig_destroy__ = _xapian.delete_RangeError
997RangeError_swigregister = _xapian.RangeError_swigregister
998RangeError_swigregister(RangeError)
999
1000class WildcardError(RuntimeError):
1001    """
1002
1003
1004    WildcardError indicates an error expanding a wildcarded query.
1005    """
1006
1007    __swig_setmethods__ = {}
1008    for _s in [RuntimeError]:
1009        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
1010    __setattr__ = lambda self, name, value: _swig_setattr(self, WildcardError, name, value)
1011    __swig_getmethods__ = {}
1012    for _s in [RuntimeError]:
1013        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
1014    __getattr__ = lambda self, name: _swig_getattr(self, WildcardError, name)
1015    __repr__ = _swig_repr
1016
1017    def __init__(self, *args):
1018        """
1019
1020
1021        Construct from message and errno value.
1022
1023        Xapian::WildcardError::WildcardError(const std::string &msg_, int
1024        errno_)
1025
1026        Parameters:
1027        -----------
1028
1029        msg_:  Message giving details of the error, intended for human
1030        consumption.
1031
1032        errno_:  Optional errno value associated with this error.
1033        """
1034        _xapian.WildcardError_swiginit(self, _xapian.new_WildcardError(*args))
1035    __swig_destroy__ = _xapian.delete_WildcardError
1036WildcardError_swigregister = _xapian.WildcardError_swigregister
1037WildcardError_swigregister(WildcardError)
1038
1039class DatabaseNotFoundError(DatabaseOpeningError):
1040    """
1041
1042
1043    Indicates an attempt to access a database not present.
1044    """
1045
1046    __swig_setmethods__ = {}
1047    for _s in [DatabaseOpeningError]:
1048        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
1049    __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseNotFoundError, name, value)
1050    __swig_getmethods__ = {}
1051    for _s in [DatabaseOpeningError]:
1052        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
1053    __getattr__ = lambda self, name: _swig_getattr(self, DatabaseNotFoundError, name)
1054    __repr__ = _swig_repr
1055
1056    def __init__(self, *args):
1057        """
1058
1059
1060        Construct from message and errno value.
1061
1062        Xapian::DatabaseNotFoundError::DatabaseNotFoundError(const std::string
1063        &msg_, int errno_)
1064
1065        Parameters:
1066        -----------
1067
1068        msg_:  Message giving details of the error, intended for human
1069        consumption.
1070
1071        errno_:  Optional errno value associated with this error.
1072        """
1073        _xapian.DatabaseNotFoundError_swiginit(self, _xapian.new_DatabaseNotFoundError(*args))
1074    __swig_destroy__ = _xapian.delete_DatabaseNotFoundError
1075DatabaseNotFoundError_swigregister = _xapian.DatabaseNotFoundError_swigregister
1076DatabaseNotFoundError_swigregister(DatabaseNotFoundError)
1077
1078class DatabaseClosedError(DatabaseError):
1079    """
1080
1081
1082    Indicates an attempt to access a closed database.
1083    """
1084
1085    __swig_setmethods__ = {}
1086    for _s in [DatabaseError]:
1087        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
1088    __setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseClosedError, name, value)
1089    __swig_getmethods__ = {}
1090    for _s in [DatabaseError]:
1091        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
1092    __getattr__ = lambda self, name: _swig_getattr(self, DatabaseClosedError, name)
1093    __repr__ = _swig_repr
1094
1095    def __init__(self, *args):
1096        """
1097
1098
1099        Construct from message and errno value.
1100
1101        Xapian::DatabaseClosedError::DatabaseClosedError(const std::string
1102        &msg_, int errno_)
1103
1104        Parameters:
1105        -----------
1106
1107        msg_:  Message giving details of the error, intended for human
1108        consumption.
1109
1110        errno_:  Optional errno value associated with this error.
1111        """
1112        _xapian.DatabaseClosedError_swiginit(self, _xapian.new_DatabaseClosedError(*args))
1113    __swig_destroy__ = _xapian.delete_DatabaseClosedError
1114DatabaseClosedError_swigregister = _xapian.DatabaseClosedError_swigregister
1115DatabaseClosedError_swigregister(DatabaseClosedError)
1116
1117
1118def version_string():
1119    return _xapian.version_string()
1120version_string = _xapian.version_string
1121
1122def major_version():
1123    return _xapian.major_version()
1124major_version = _xapian.major_version
1125
1126def minor_version():
1127    return _xapian.minor_version()
1128minor_version = _xapian.minor_version
1129
1130def revision():
1131    return _xapian.revision()
1132revision = _xapian.revision
1133BAD_VALUENO = _xapian.BAD_VALUENO
1134DB_CREATE = _xapian.DB_CREATE
1135DB_CREATE_OR_OPEN = _xapian.DB_CREATE_OR_OPEN
1136DB_CREATE_OR_OVERWRITE = _xapian.DB_CREATE_OR_OVERWRITE
1137DB_OPEN = _xapian.DB_OPEN
1138DB_NO_SYNC = _xapian.DB_NO_SYNC
1139DB_FULL_SYNC = _xapian.DB_FULL_SYNC
1140DB_DANGEROUS = _xapian.DB_DANGEROUS
1141DB_NO_TERMLIST = _xapian.DB_NO_TERMLIST
1142DB_BACKEND_CHERT = _xapian.DB_BACKEND_CHERT
1143DB_BACKEND_GLASS = _xapian.DB_BACKEND_GLASS
1144DB_BACKEND_INMEMORY = _xapian.DB_BACKEND_INMEMORY
1145DB_BACKEND_STUB = _xapian.DB_BACKEND_STUB
1146DB_RETRY_LOCK = _xapian.DB_RETRY_LOCK
1147DBCHECK_SHORT_TREE = _xapian.DBCHECK_SHORT_TREE
1148DBCHECK_FULL_TREE = _xapian.DBCHECK_FULL_TREE
1149DBCHECK_SHOW_FREELIST = _xapian.DBCHECK_SHOW_FREELIST
1150DBCHECK_SHOW_STATS = _xapian.DBCHECK_SHOW_STATS
1151DBCHECK_FIX = _xapian.DBCHECK_FIX
1152DBCOMPACT_MULTIPASS = _xapian.DBCOMPACT_MULTIPASS
1153DBCOMPACT_NO_RENUMBER = _xapian.DBCOMPACT_NO_RENUMBER
1154DBCOMPACT_SINGLE_FILE = _xapian.DBCOMPACT_SINGLE_FILE
1155DOC_ASSUME_VALID = _xapian.DOC_ASSUME_VALID
1156class _PositionIterator(object):
1157    """
1158
1159
1160    Class for iterating over term positions.
1161    """
1162
1163    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
1164    __repr__ = _swig_repr
1165
1166    def __init__(self):
1167        """
1168
1169
1170        Default constructor.
1171
1172        Xapian::PositionIterator::PositionIterator()
1173
1174        Creates an uninitialised iterator, which can't be used before being
1175        assigned to, but is sometimes syntactically convenient.
1176        """
1177        _xapian._PositionIterator_swiginit(self, _xapian.new__PositionIterator())
1178    __swig_destroy__ = _xapian.delete__PositionIterator
1179
1180    def skip_to(self, termpos):
1181        """
1182
1183
1184        Advance the iterator to term position termpos.
1185
1186        void Xapian::PositionIterator::skip_to(Xapian::termpos termpos)
1187
1188        Parameters:
1189        -----------
1190
1191        termpos:  The position to advance to. If this position isn't in the
1192        stream being iterated, then the iterator is moved to the next term
1193        position after it which is.
1194        """
1195        return _xapian._PositionIterator_skip_to(self, termpos)
1196
1197
1198    def __str__(self):
1199        """
1200
1201
1202        Return a string describing this object.
1203
1204        std::string Xapian::PositionIterator::get_description() const
1205        """
1206        return _xapian._PositionIterator___str__(self)
1207
1208_PositionIterator.skip_to = _xapian.SWIG_PyInstanceMethod_New(_xapian._PositionIterator_skip_to)
1209_PositionIterator.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._PositionIterator___str__)
1210_PositionIterator.__eq__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._PositionIterator___eq__)
1211_PositionIterator.__ne__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._PositionIterator___ne__)
1212_PositionIterator.equals = _xapian.SWIG_PyInstanceMethod_New(_xapian._PositionIterator_equals)
1213_PositionIterator.get_termpos = _xapian.SWIG_PyInstanceMethod_New(_xapian._PositionIterator_get_termpos)
1214_PositionIterator.__next__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._PositionIterator___next__)
1215_PositionIterator_swigregister = _xapian._PositionIterator_swigregister
1216_PositionIterator_swigregister(_PositionIterator)
1217
1218class _PostingIterator(object):
1219    """
1220
1221
1222    Class for iterating over a list of terms.
1223    """
1224
1225    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
1226    __repr__ = _swig_repr
1227
1228    def __init__(self):
1229        """
1230
1231
1232        Default constructor.
1233
1234        Xapian::PostingIterator::PostingIterator()
1235
1236        Creates an uninitialised iterator, which can't be used before being
1237        assigned to, but is sometimes syntactically convenient.
1238        """
1239        _xapian._PostingIterator_swiginit(self, _xapian.new__PostingIterator())
1240    __swig_destroy__ = _xapian.delete__PostingIterator
1241
1242    def get_wdf(self):
1243        """
1244
1245
1246        Return the wdf for the document at the current position.
1247
1248        Xapian::termcount Xapian::PostingIterator::get_wdf() const
1249        """
1250        return _xapian._PostingIterator_get_wdf(self)
1251
1252
1253    def get_doclength(self):
1254        """
1255
1256
1257        Return the length of the document at the current position.
1258
1259        Xapian::termcount Xapian::PostingIterator::get_doclength() const
1260        """
1261        return _xapian._PostingIterator_get_doclength(self)
1262
1263
1264    def get_unique_terms(self):
1265        """
1266
1267
1268        Return the number of unique terms in the current document.
1269
1270        Xapian::termcount Xapian::PostingIterator::get_unique_terms() const
1271        """
1272        return _xapian._PostingIterator_get_unique_terms(self)
1273
1274
1275    def _positionlist_begin(self):
1276        """
1277
1278
1279        Return a PositionIterator for the current document.
1280
1281        PositionIterator Xapian::PostingIterator::positionlist_begin() const
1282
1283        """
1284        return _xapian._PostingIterator__positionlist_begin(self)
1285
1286
1287    def _positionlist_end(self):
1288        """
1289
1290
1291        Return an end PositionIterator for the current document.
1292
1293        PositionIterator Xapian::PostingIterator::positionlist_end() const
1294        """
1295        return _xapian._PostingIterator__positionlist_end(self)
1296
1297
1298    def skip_to(self, did):
1299        """
1300
1301
1302        Advance the iterator to document did.
1303
1304        void Xapian::PostingIterator::skip_to(Xapian::docid did)
1305
1306        Parameters:
1307        -----------
1308
1309        did:  The document id to advance to. If this document id isn't in the
1310        stream being iterated, then the iterator is moved to the next document
1311        id after it which is.
1312        """
1313        return _xapian._PostingIterator_skip_to(self, did)
1314
1315
1316    def __str__(self):
1317        """
1318
1319
1320        Return a string describing this object.
1321
1322        std::string Xapian::PostingIterator::get_description() const
1323        """
1324        return _xapian._PostingIterator___str__(self)
1325
1326_PostingIterator.get_wdf = _xapian.SWIG_PyInstanceMethod_New(_xapian._PostingIterator_get_wdf)
1327_PostingIterator.get_doclength = _xapian.SWIG_PyInstanceMethod_New(_xapian._PostingIterator_get_doclength)
1328_PostingIterator.get_unique_terms = _xapian.SWIG_PyInstanceMethod_New(_xapian._PostingIterator_get_unique_terms)
1329_PostingIterator._positionlist_begin = _xapian.SWIG_PyInstanceMethod_New(_xapian._PostingIterator__positionlist_begin)
1330_PostingIterator._positionlist_end = _xapian.SWIG_PyInstanceMethod_New(_xapian._PostingIterator__positionlist_end)
1331_PostingIterator.skip_to = _xapian.SWIG_PyInstanceMethod_New(_xapian._PostingIterator_skip_to)
1332_PostingIterator.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._PostingIterator___str__)
1333_PostingIterator.__eq__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._PostingIterator___eq__)
1334_PostingIterator.__ne__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._PostingIterator___ne__)
1335_PostingIterator.equals = _xapian.SWIG_PyInstanceMethod_New(_xapian._PostingIterator_equals)
1336_PostingIterator.get_docid = _xapian.SWIG_PyInstanceMethod_New(_xapian._PostingIterator_get_docid)
1337_PostingIterator.__next__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._PostingIterator___next__)
1338_PostingIterator_swigregister = _xapian._PostingIterator_swigregister
1339_PostingIterator_swigregister(_PostingIterator)
1340
1341class _TermIterator(object):
1342    """
1343
1344
1345    Class for iterating over a list of terms.
1346    """
1347
1348    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
1349    __repr__ = _swig_repr
1350
1351    def __init__(self):
1352        """
1353
1354
1355        Default constructor.
1356
1357        Xapian::TermIterator::TermIterator()
1358
1359        Creates an uninitialised iterator, which can't be used before being
1360        assigned to, but is sometimes syntactically convenient.
1361        """
1362        _xapian._TermIterator_swiginit(self, _xapian.new__TermIterator())
1363    __swig_destroy__ = _xapian.delete__TermIterator
1364
1365    def get_wdf(self):
1366        """
1367
1368
1369        Return the wdf for the term at the current position.
1370
1371        Xapian::termcount Xapian::TermIterator::get_wdf() const
1372        """
1373        return _xapian._TermIterator_get_wdf(self)
1374
1375
1376    def get_termfreq(self):
1377        """
1378
1379
1380        Return the term frequency for the term at the current position.
1381
1382        Xapian::doccount Xapian::TermIterator::get_termfreq() const
1383        """
1384        return _xapian._TermIterator_get_termfreq(self)
1385
1386
1387    def positionlist_count(self):
1388        """
1389
1390
1391        Return the length of the position list for the current position.
1392
1393        Xapian::termcount Xapian::TermIterator::positionlist_count() const
1394        """
1395        return _xapian._TermIterator_positionlist_count(self)
1396
1397
1398    def _positionlist_begin(self):
1399        """
1400
1401
1402        Return a PositionIterator for the current term.
1403
1404        PositionIterator Xapian::TermIterator::positionlist_begin() const
1405        """
1406        return _xapian._TermIterator__positionlist_begin(self)
1407
1408
1409    def _positionlist_end(self):
1410        """
1411
1412
1413        Return an end PositionIterator for the current term.
1414
1415        PositionIterator Xapian::TermIterator::positionlist_end() const
1416        """
1417        return _xapian._TermIterator__positionlist_end(self)
1418
1419
1420    def skip_to(self, term):
1421        """
1422
1423
1424        Advance the iterator to term term.
1425
1426        void Xapian::TermIterator::skip_to(const std::string &term)
1427
1428        If the iteration is over an unsorted list of terms, then this method
1429        will throw Xapian::InvalidOperationError.
1430
1431        Parameters:
1432        -----------
1433
1434        term:  The term to advance to. If this term isn't in the stream being
1435        iterated, then the iterator is moved to the next term after it which
1436        is.
1437        """
1438        return _xapian._TermIterator_skip_to(self, term)
1439
1440
1441    def __str__(self):
1442        """
1443
1444
1445        Return a string describing this object.
1446
1447        std::string Xapian::TermIterator::get_description() const
1448        """
1449        return _xapian._TermIterator___str__(self)
1450
1451_TermIterator.get_wdf = _xapian.SWIG_PyInstanceMethod_New(_xapian._TermIterator_get_wdf)
1452_TermIterator.get_termfreq = _xapian.SWIG_PyInstanceMethod_New(_xapian._TermIterator_get_termfreq)
1453_TermIterator.positionlist_count = _xapian.SWIG_PyInstanceMethod_New(_xapian._TermIterator_positionlist_count)
1454_TermIterator._positionlist_begin = _xapian.SWIG_PyInstanceMethod_New(_xapian._TermIterator__positionlist_begin)
1455_TermIterator._positionlist_end = _xapian.SWIG_PyInstanceMethod_New(_xapian._TermIterator__positionlist_end)
1456_TermIterator.skip_to = _xapian.SWIG_PyInstanceMethod_New(_xapian._TermIterator_skip_to)
1457_TermIterator.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._TermIterator___str__)
1458_TermIterator.__eq__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._TermIterator___eq__)
1459_TermIterator.__ne__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._TermIterator___ne__)
1460_TermIterator.equals = _xapian.SWIG_PyInstanceMethod_New(_xapian._TermIterator_equals)
1461_TermIterator.get_term = _xapian.SWIG_PyInstanceMethod_New(_xapian._TermIterator_get_term)
1462_TermIterator.__next__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._TermIterator___next__)
1463_TermIterator_swigregister = _xapian._TermIterator_swigregister
1464_TermIterator_swigregister(_TermIterator)
1465
1466class _ValueIterator(object):
1467    """
1468
1469
1470    Class for iterating over document values.
1471    """
1472
1473    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
1474    __repr__ = _swig_repr
1475
1476    def __init__(self):
1477        """
1478
1479
1480        Default constructor.
1481
1482        Xapian::ValueIterator::ValueIterator()
1483
1484        Creates an uninitialised iterator, which can't be used before being
1485        assigned to, but is sometimes syntactically convenient.
1486        """
1487        _xapian._ValueIterator_swiginit(self, _xapian.new__ValueIterator())
1488    __swig_destroy__ = _xapian.delete__ValueIterator
1489
1490    def get_docid(self):
1491        """
1492
1493
1494        Return the docid at the current position.
1495
1496        Xapian::docid Xapian::ValueIterator::get_docid() const
1497
1498        If we're iterating over values of a document, this method will throw
1499        Xapian::InvalidOperationError.
1500        """
1501        return _xapian._ValueIterator_get_docid(self)
1502
1503
1504    def get_valueno(self):
1505        """
1506
1507
1508        Return the value slot number for the current position.
1509
1510        Xapian::valueno Xapian::ValueIterator::get_valueno() const
1511
1512        If the iterator is over all values in a slot, this returns that slot's
1513        number. If the iterator is over the values in a particular document,
1514        it returns the number of each slot in turn.
1515        """
1516        return _xapian._ValueIterator_get_valueno(self)
1517
1518
1519    def skip_to(self, docid_or_slot):
1520        """
1521
1522
1523        Advance the iterator to document id or value slot docid_or_slot.
1524
1525        void Xapian::ValueIterator::skip_to(Xapian::docid docid_or_slot)
1526
1527        If this iterator is over values in a document, then this method
1528        advances the iterator to value slot docid_or_slot, or the first slot
1529        after it if there is no value in slot slot.
1530
1531        If this iterator is over values in a particular slot, then this method
1532        advances the iterator to document id docid_or_slot, or the first
1533        document id after it if there is no value in the slot we're iterating
1534        over for document docid_or_slot.
1535
1536        Note: The "two-faced" nature of this method is due to how C++
1537        overloading works. Xapian::docid and Xapian::valueno are both typedefs
1538        for the same unsigned integer type, so overloading can't distinguish
1539        them.
1540
1541        Parameters:
1542        -----------
1543
1544        docid_or_slot:  The docid/slot to advance to.
1545        """
1546        return _xapian._ValueIterator_skip_to(self, docid_or_slot)
1547
1548
1549    def check(self, docid):
1550        """
1551
1552
1553        Check if the specified docid occurs.
1554
1555        bool Xapian::ValueIterator::check(Xapian::docid docid)
1556
1557        The caller is required to ensure that the specified document id did
1558        actually exists in the database.
1559
1560        This method acts like skip_to() if that can be done at little extra
1561        cost, in which case it then returns true. This is how chert and glass
1562        databases behave because they store values in streams which allow for
1563        an efficient implementation of skip_to().
1564
1565        Otherwise it simply checks if a particular docid is present. If it is,
1566        it returns true. If it isn't, it returns false, and leaves the
1567        position unspecified (and hence the result of calling methods which
1568        depend on the current position, such as get_docid(), are also
1569        unspecified). In this state, next() will advance to the first matching
1570        position after document did, and skip_to() will act as it would if the
1571        position was the first matching position after document did.
1572
1573        Currently the inmemory and remote backends behave in the latter way
1574        because they don't support streamed values and so skip_to() must check
1575        each document it skips over which is significantly slower.
1576
1577        Parameters:
1578        -----------
1579
1580        docid:  The document id to check.
1581        """
1582        return _xapian._ValueIterator_check(self, docid)
1583
1584
1585    def __str__(self):
1586        """
1587
1588
1589        Return a string describing this object.
1590
1591        std::string Xapian::ValueIterator::get_description() const
1592        """
1593        return _xapian._ValueIterator___str__(self)
1594
1595_ValueIterator.get_docid = _xapian.SWIG_PyInstanceMethod_New(_xapian._ValueIterator_get_docid)
1596_ValueIterator.get_valueno = _xapian.SWIG_PyInstanceMethod_New(_xapian._ValueIterator_get_valueno)
1597_ValueIterator.skip_to = _xapian.SWIG_PyInstanceMethod_New(_xapian._ValueIterator_skip_to)
1598_ValueIterator.check = _xapian.SWIG_PyInstanceMethod_New(_xapian._ValueIterator_check)
1599_ValueIterator.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._ValueIterator___str__)
1600_ValueIterator.__eq__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._ValueIterator___eq__)
1601_ValueIterator.__ne__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._ValueIterator___ne__)
1602_ValueIterator.equals = _xapian.SWIG_PyInstanceMethod_New(_xapian._ValueIterator_equals)
1603_ValueIterator.get_value = _xapian.SWIG_PyInstanceMethod_New(_xapian._ValueIterator_get_value)
1604_ValueIterator.__next__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._ValueIterator___next__)
1605_ValueIterator_swigregister = _xapian._ValueIterator_swigregister
1606_ValueIterator_swigregister(_ValueIterator)
1607
1608class Document(object):
1609    """
1610
1611
1612    A handle representing a document in a Xapian database.
1613
1614    The Document class fetches information from the database lazily.
1615    Usually this behaviour isn't visible to users (except for the speed
1616    benefits), but if the document in the database is modified or deleted,
1617    then preexisting Document objects may return the old or new versions
1618    of data (or throw Xapian::DocNotFoundError in the case of deletion).
1619
1620    Since Database objects work on a snapshot of the database's state, the
1621    situation above can only happen with a WritableDatabase object, or if
1622    you call Database::reopen() on a Database object.
1623
1624    We recommend you avoid designs where this behaviour is an issue, but
1625    if you need a way to make a non-lazy version of a Document object, you
1626    can do this like so:doc =
1627    Xapian::Document::unserialise(doc.serialise());
1628    """
1629
1630    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
1631    __repr__ = _swig_repr
1632
1633    def __init__(self):
1634        """
1635
1636
1637        Make a new empty Document.
1638
1639        Xapian::Document::Document()
1640        """
1641        _xapian.Document_swiginit(self, _xapian.new_Document())
1642    __swig_destroy__ = _xapian.delete_Document
1643
1644    def get_value(self, slot):
1645        """
1646
1647
1648        Get value by number.
1649
1650        std::string Xapian::Document::get_value(Xapian::valueno slot) const
1651
1652        Returns an empty string if no value with the given number is present
1653        in the document.
1654
1655        Parameters:
1656        -----------
1657
1658        slot:  The number of the value.
1659        """
1660        return _xapian.Document_get_value(self, slot)
1661
1662
1663    def add_value(self, slot, value):
1664        """
1665
1666
1667        Add a new value.
1668
1669        void Xapian::Document::add_value(Xapian::valueno slot, const
1670        std::string &value)
1671
1672        The new value will replace any existing value with the same number (or
1673        if the new value is empty, it will remove any existing value with the
1674        same number).
1675
1676        Parameters:
1677        -----------
1678
1679        slot:  The value slot to add the value in.
1680
1681        value:  The value to set.
1682        """
1683        return _xapian.Document_add_value(self, slot, value)
1684
1685
1686    def remove_value(self, slot):
1687        """
1688
1689
1690        Remove any value with the given number.
1691
1692        void Xapian::Document::remove_value(Xapian::valueno slot)
1693        """
1694        return _xapian.Document_remove_value(self, slot)
1695
1696
1697    def clear_values(self):
1698        """
1699
1700
1701        Remove all values associated with the document.
1702
1703        void Xapian::Document::clear_values()
1704        """
1705        return _xapian.Document_clear_values(self)
1706
1707
1708    def get_data(self):
1709        """
1710
1711
1712        Get data stored in the document.
1713
1714        std::string Xapian::Document::get_data() const
1715
1716        This is potentially a relatively expensive operation, and shouldn't
1717        normally be used during the match (e.g. in a PostingSource or match
1718        decider functor. Put data for use by match deciders in a value
1719        instead.
1720        """
1721        return _xapian.Document_get_data(self)
1722
1723
1724    def set_data(self, data):
1725        """
1726
1727
1728        Set data stored in the document.
1729
1730        void Xapian::Document::set_data(const std::string &data)
1731
1732        Xapian treats the data as an opaque blob. It may try to compress it,
1733        but other than that it will just store it and return it when
1734        requested.
1735
1736        Parameters:
1737        -----------
1738
1739        data:  The data to store.
1740        """
1741        return _xapian.Document_set_data(self, data)
1742
1743
1744    def add_posting(self, tname, tpos, wdfinc=1):
1745        """
1746
1747
1748        Add an occurrence of a term at a particular position.
1749
1750        void Xapian::Document::add_posting(const std::string &tname,
1751        Xapian::termpos tpos, Xapian::termcount wdfinc=1)
1752
1753        Multiple occurrences of the term at the same position are represented
1754        only once in the positional information, but do increase the wdf.
1755
1756        If the term is not already in the document, it will be added to it.
1757
1758        Parameters:
1759        -----------
1760
1761        tname:  The name of the term.
1762
1763        tpos:  The position of the term.
1764
1765        wdfinc:  The increment that will be applied to the wdf for this term.
1766
1767        """
1768        return _xapian.Document_add_posting(self, tname, tpos, wdfinc)
1769
1770
1771    def add_term(self, tname, wdfinc=1):
1772        """
1773
1774
1775        Add a term to the document, without positional information.
1776
1777        void Xapian::Document::add_term(const std::string &tname,
1778        Xapian::termcount wdfinc=1)
1779
1780        Any existing positional information for the term will be left
1781        unmodified.
1782
1783        Parameters:
1784        -----------
1785
1786        tname:  The name of the term.
1787
1788        wdfinc:  The increment that will be applied to the wdf for this term
1789        (default: 1).
1790        """
1791        return _xapian.Document_add_term(self, tname, wdfinc)
1792
1793
1794    def add_boolean_term(self, term):
1795        """
1796
1797
1798        Add a boolean filter term to the document.
1799
1800        void Xapian::Document::add_boolean_term(const std::string &term)
1801
1802        This method adds term to the document with wdf of 0 - this is
1803        generally what you want for a term used for boolean filtering as the
1804        wdf of such terms is ignored, and it doesn't make sense for them to
1805        contribute to the document's length.
1806
1807        If the specified term already indexes this document, this method has
1808        no effect.
1809
1810        It is exactly the same as add_term(term, 0).
1811
1812        This method was added in Xapian 1.0.18.
1813
1814        Parameters:
1815        -----------
1816
1817        term:  The term to add.
1818        """
1819        return _xapian.Document_add_boolean_term(self, term)
1820
1821
1822    def remove_posting(self, tname, tpos, wdfdec=1):
1823        """
1824
1825
1826        Remove a posting of a term from the document.
1827
1828        void Xapian::Document::remove_posting(const std::string &tname,
1829        Xapian::termpos tpos, Xapian::termcount wdfdec=1)
1830
1831        Note that the term will still index the document even if all
1832        occurrences are removed. To remove a term from a document completely,
1833        use remove_term().
1834
1835        Parameters:
1836        -----------
1837
1838        tname:  The name of the term.
1839
1840        tpos:  The position of the term.
1841
1842        wdfdec:  The decrement that will be applied to the wdf when removing
1843        this posting. The wdf will not go below the value of 0.
1844
1845        Parameters:
1846        -----------
1847
1848        Xapian::InvalidArgumentError:  will be thrown if the term is not at
1849        the position specified in the position list for this term in this
1850        document.
1851
1852        Xapian::InvalidArgumentError:  will be thrown if the term is not in
1853        the document
1854        """
1855        return _xapian.Document_remove_posting(self, tname, tpos, wdfdec)
1856
1857
1858    def remove_postings(self, term, term_pos_first, term_pos_last, wdf_dec=1):
1859        """
1860
1861
1862        Remove a range of postings for a term.
1863
1864        Xapian::termpos Xapian::Document::remove_postings(const std::string
1865        &term, Xapian::termpos term_pos_first, Xapian::termpos term_pos_last,
1866        Xapian::termcount wdf_dec=1)
1867
1868        Any instances of the term at positions >= term_pos_first and <=
1869        term_pos_last will be removed, and the wdf reduced by wdf_dec for each
1870        instance removed (the wdf will not ever go below zero though).
1871
1872        It's OK if the term doesn't occur in the range of positions specified
1873        (unlike  remove_posting()). And if term_pos_first > term_pos_last,
1874        this method does nothing.
1875
1876        The number of postings removed.
1877
1878        Parameters:
1879        -----------
1880
1881        Xapian::InvalidArgumentError:  will be thrown if the term is not in
1882        the document
1883
1884        Added in Xapian 1.4.8.
1885        """
1886        return _xapian.Document_remove_postings(self, term, term_pos_first, term_pos_last, wdf_dec)
1887
1888
1889    def remove_term(self, tname):
1890        """
1891
1892
1893        Remove a term and all postings associated with it.
1894
1895        void Xapian::Document::remove_term(const std::string &tname)
1896
1897        Parameters:
1898        -----------
1899
1900        tname:  The name of the term.
1901
1902        Parameters:
1903        -----------
1904
1905        Xapian::InvalidArgumentError:  will be thrown if the term is not in
1906        the document
1907        """
1908        return _xapian.Document_remove_term(self, tname)
1909
1910
1911    def clear_terms(self):
1912        """
1913
1914
1915        Remove all terms (and postings) from the document.
1916
1917        void Xapian::Document::clear_terms()
1918        """
1919        return _xapian.Document_clear_terms(self)
1920
1921
1922    def termlist_count(self):
1923        """
1924
1925
1926        The length of the termlist - i.e.
1927
1928        Xapian::termcount Xapian::Document::termlist_count() const
1929
1930        the number of different terms which index this document.
1931        """
1932        return _xapian.Document_termlist_count(self)
1933
1934
1935    def _termlist_begin(self):
1936        """
1937
1938
1939        Iterator for the terms in this document.
1940
1941        TermIterator Xapian::Document::termlist_begin() const
1942        """
1943        return _xapian.Document__termlist_begin(self)
1944
1945
1946    def _termlist_end(self):
1947        """
1948
1949
1950        Equivalent end iterator for termlist_begin().
1951
1952        TermIterator Xapian::Document::termlist_end() const
1953        """
1954        return _xapian.Document__termlist_end(self)
1955
1956
1957    def values_count(self):
1958        """
1959
1960
1961        Count the values in this document.
1962
1963        Xapian::termcount Xapian::Document::values_count() const
1964        """
1965        return _xapian.Document_values_count(self)
1966
1967
1968    def _values_begin(self):
1969        """
1970
1971
1972        Iterator for the values in this document.
1973
1974        ValueIterator Xapian::Document::values_begin() const
1975        """
1976        return _xapian.Document__values_begin(self)
1977
1978
1979    def _values_end(self):
1980        """
1981
1982
1983        Equivalent end iterator for values_begin().
1984
1985        ValueIterator Xapian::Document::values_end() const
1986        """
1987        return _xapian.Document__values_end(self)
1988
1989
1990    def get_docid(self):
1991        """
1992
1993
1994        Get the document id which is associated with this document (if any).
1995
1996        docid Xapian::Document::get_docid() const
1997
1998        NB If multiple databases are being searched together, then this will
1999        be the document id in the individual database, not the merged
2000        database!
2001
2002        If this document came from a database, return the document id in that
2003        database. Otherwise, return 0 (in Xapian 1.0.22/1.2.4 or later; prior
2004        to this the returned value was uninitialised).
2005        """
2006        return _xapian.Document_get_docid(self)
2007
2008
2009    def serialise(self):
2010        """
2011
2012
2013        Serialise document into a string.
2014
2015        std::string Xapian::Document::serialise() const
2016
2017        The document representation may change between Xapian releases: even
2018        between minor versions. However, it is guaranteed not to change if the
2019        remote database protocol has not changed between releases.
2020        """
2021        return _xapian.Document_serialise(self)
2022
2023    unserialise = staticmethod(_xapian.Document_unserialise)
2024
2025    def __str__(self):
2026        """
2027
2028
2029        Return a string describing this object.
2030
2031        std::string Xapian::Document::get_description() const
2032        """
2033        return _xapian.Document___str__(self)
2034
2035Document.get_value = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document_get_value)
2036Document.add_value = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document_add_value)
2037Document.remove_value = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document_remove_value)
2038Document.clear_values = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document_clear_values)
2039Document.get_data = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document_get_data)
2040Document.set_data = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document_set_data)
2041Document.add_posting = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document_add_posting)
2042Document.add_term = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document_add_term)
2043Document.add_boolean_term = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document_add_boolean_term)
2044Document.remove_posting = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document_remove_posting)
2045Document.remove_postings = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document_remove_postings)
2046Document.remove_term = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document_remove_term)
2047Document.clear_terms = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document_clear_terms)
2048Document.termlist_count = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document_termlist_count)
2049Document._termlist_begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document__termlist_begin)
2050Document._termlist_end = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document__termlist_end)
2051Document.values_count = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document_values_count)
2052Document._values_begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document__values_begin)
2053Document._values_end = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document__values_end)
2054Document.get_docid = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document_get_docid)
2055Document.serialise = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document_serialise)
2056Document.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.Document___str__)
2057Document_swigregister = _xapian.Document_swigregister
2058Document_swigregister(Document)
2059
2060def Document_unserialise(serialised):
2061    return _xapian.Document_unserialise(serialised)
2062Document_unserialise = _xapian.Document_unserialise
2063
2064class Registry(object):
2065    """
2066
2067
2068    Registry for user subclasses.
2069
2070    This class provides a way for the remote server to look up user
2071    subclasses when unserialising.
2072    """
2073
2074    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
2075    __repr__ = _swig_repr
2076
2077    def __init__(self):
2078        """
2079
2080
2081        Default constructor.
2082
2083        Xapian::Registry::Registry()
2084
2085        The registry will contain all standard subclasses of user-subclassable
2086        classes.
2087        """
2088        _xapian.Registry_swiginit(self, _xapian.new_Registry())
2089    __swig_destroy__ = _xapian.delete_Registry
2090
2091    def register_weighting_scheme(self, wt):
2092        """
2093
2094
2095        Register a weighting scheme.
2096
2097        void Xapian::Registry::register_weighting_scheme(const Xapian::Weight
2098        &wt)
2099
2100        Parameters:
2101        -----------
2102
2103        wt:  The weighting scheme to register.
2104        """
2105        return _xapian.Registry_register_weighting_scheme(self, wt)
2106
2107
2108    def get_weighting_scheme(self, name):
2109        """
2110
2111
2112        Get the weighting scheme given a name.
2113
2114        const Xapian::Weight* Xapian::Registry::get_weighting_scheme(const
2115        std::string &name) const
2116
2117        Parameters:
2118        -----------
2119
2120        name:  The name of the weighting scheme to find.
2121
2122        An object with the requested name, or NULL if the weighting scheme
2123        could not be found. The returned object is owned by the registry and
2124        so must not be deleted by the caller.
2125        """
2126        return _xapian.Registry_get_weighting_scheme(self, name)
2127
2128
2129    def register_posting_source(self, source):
2130        """
2131
2132
2133        Register a user-defined posting source class.
2134
2135        void Xapian::Registry::register_posting_source(const
2136        Xapian::PostingSource &source)
2137
2138        Parameters:
2139        -----------
2140
2141        source:  The posting source to register.
2142        """
2143        return _xapian.Registry_register_posting_source(self, source)
2144
2145
2146    def get_posting_source(self, name):
2147        """
2148
2149
2150        Get a posting source given a name.
2151
2152        const Xapian::PostingSource*
2153        Xapian::Registry::get_posting_source(const std::string &name) const
2154
2155        Parameters:
2156        -----------
2157
2158        name:  The name of the posting source to find.
2159
2160        An object with the requested name, or NULL if the posting source could
2161        not be found. The returned object is owned by the registry and so must
2162        not be deleted by the caller.
2163        """
2164        return _xapian.Registry_get_posting_source(self, name)
2165
2166
2167    def register_match_spy(self, spy):
2168        """
2169
2170
2171        Register a user-defined match spy class.
2172
2173        void Xapian::Registry::register_match_spy(const Xapian::MatchSpy &spy)
2174
2175        Parameters:
2176        -----------
2177
2178        spy:  The match spy to register.
2179        """
2180        return _xapian.Registry_register_match_spy(self, spy)
2181
2182
2183    def get_match_spy(self, name):
2184        """
2185
2186
2187        Get a match spy given a name.
2188
2189        const Xapian::MatchSpy* Xapian::Registry::get_match_spy(const
2190        std::string &name) const
2191
2192        Parameters:
2193        -----------
2194
2195        name:  The name of the match spy to find.
2196
2197        An object with the requested name, or NULL if the match spy could not
2198        be found. The returned object is owned by the registry and so must not
2199        be deleted by the caller.
2200        """
2201        return _xapian.Registry_get_match_spy(self, name)
2202
2203
2204    def register_lat_long_metric(self, metric):
2205        """
2206
2207
2208        Register a user-defined lat-long metric class.
2209
2210        void Xapian::Registry::register_lat_long_metric(const
2211        Xapian::LatLongMetric &metric)
2212        """
2213        return _xapian.Registry_register_lat_long_metric(self, metric)
2214
2215
2216    def get_lat_long_metric(self, name):
2217        """
2218
2219
2220        Get a lat-long metric given a name.
2221
2222        const Xapian::LatLongMetric*
2223        Xapian::Registry::get_lat_long_metric(const std::string &name) const
2224
2225        The returned metric is owned by the registry object.
2226
2227        Returns NULL if the metric could not be found.
2228        """
2229        return _xapian.Registry_get_lat_long_metric(self, name)
2230
2231Registry.register_weighting_scheme = _xapian.SWIG_PyInstanceMethod_New(_xapian.Registry_register_weighting_scheme)
2232Registry.get_weighting_scheme = _xapian.SWIG_PyInstanceMethod_New(_xapian.Registry_get_weighting_scheme)
2233Registry.register_posting_source = _xapian.SWIG_PyInstanceMethod_New(_xapian.Registry_register_posting_source)
2234Registry.get_posting_source = _xapian.SWIG_PyInstanceMethod_New(_xapian.Registry_get_posting_source)
2235Registry.register_match_spy = _xapian.SWIG_PyInstanceMethod_New(_xapian.Registry_register_match_spy)
2236Registry.get_match_spy = _xapian.SWIG_PyInstanceMethod_New(_xapian.Registry_get_match_spy)
2237Registry.register_lat_long_metric = _xapian.SWIG_PyInstanceMethod_New(_xapian.Registry_register_lat_long_metric)
2238Registry.get_lat_long_metric = _xapian.SWIG_PyInstanceMethod_New(_xapian.Registry_get_lat_long_metric)
2239Registry_swigregister = _xapian.Registry_swigregister
2240Registry_swigregister(Registry)
2241
2242class Query(object):
2243    """
2244
2245
2246    Class representing a query.
2247    """
2248
2249    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
2250    __repr__ = _swig_repr
2251    OP_AND = _xapian.Query_OP_AND
2252    OP_OR = _xapian.Query_OP_OR
2253    OP_AND_NOT = _xapian.Query_OP_AND_NOT
2254    OP_XOR = _xapian.Query_OP_XOR
2255    OP_AND_MAYBE = _xapian.Query_OP_AND_MAYBE
2256    OP_FILTER = _xapian.Query_OP_FILTER
2257    OP_NEAR = _xapian.Query_OP_NEAR
2258    OP_PHRASE = _xapian.Query_OP_PHRASE
2259    OP_VALUE_RANGE = _xapian.Query_OP_VALUE_RANGE
2260    OP_SCALE_WEIGHT = _xapian.Query_OP_SCALE_WEIGHT
2261    OP_ELITE_SET = _xapian.Query_OP_ELITE_SET
2262    OP_VALUE_GE = _xapian.Query_OP_VALUE_GE
2263    OP_VALUE_LE = _xapian.Query_OP_VALUE_LE
2264    OP_SYNONYM = _xapian.Query_OP_SYNONYM
2265    OP_MAX = _xapian.Query_OP_MAX
2266    OP_WILDCARD = _xapian.Query_OP_WILDCARD
2267    OP_INVALID = _xapian.Query_OP_INVALID
2268    WILDCARD_LIMIT_ERROR = _xapian.Query_WILDCARD_LIMIT_ERROR
2269    WILDCARD_LIMIT_FIRST = _xapian.Query_WILDCARD_LIMIT_FIRST
2270    WILDCARD_LIMIT_MOST_FREQUENT = _xapian.Query_WILDCARD_LIMIT_MOST_FREQUENT
2271    __swig_destroy__ = _xapian.delete_Query
2272
2273    def _get_terms_begin(self):
2274        """
2275
2276
2277        Begin iterator for terms in the query object.
2278
2279        const TermIterator Xapian::Query::get_terms_begin() const
2280
2281        The iterator returns terms in ascending query position order, and will
2282        return the same term in each unique position it occurs in. If you want
2283        the terms in sorted order and without duplicates, see
2284        get_unique_terms_begin().
2285        """
2286        return _xapian.Query__get_terms_begin(self)
2287
2288
2289    def _get_terms_end(self):
2290        """
2291
2292
2293        End iterator for terms in the query object.
2294
2295        const TermIterator Xapian::Query::get_terms_end() const
2296        """
2297        return _xapian.Query__get_terms_end(self)
2298
2299
2300    def get_unique_terms_begin(self):
2301        """
2302
2303
2304        Begin iterator for unique terms in the query object.
2305
2306        const TermIterator Xapian::Query::get_unique_terms_begin() const
2307
2308        Terms are sorted and terms with the same name removed from the list.
2309
2310        If you want the terms in ascending query position order, see
2311        get_terms_begin().
2312        """
2313        return _xapian.Query_get_unique_terms_begin(self)
2314
2315
2316    def get_unique_terms_end(self):
2317        """
2318
2319
2320        End iterator for unique terms in the query object.
2321
2322        const TermIterator Xapian::Query::get_unique_terms_end() const
2323        """
2324        return _xapian.Query_get_unique_terms_end(self)
2325
2326
2327    def get_length(self):
2328        """
2329
2330
2331        Return the length of this query object.
2332
2333        Xapian::termcount Xapian::Query::get_length() const
2334        """
2335        return _xapian.Query_get_length(self)
2336
2337
2338    def empty(self):
2339        """
2340
2341
2342        Check if this query is Xapian::Query::MatchNothing.
2343
2344        bool Xapian::Query::empty() const
2345        """
2346        return _xapian.Query_empty(self)
2347
2348
2349    def serialise(self):
2350        """
2351
2352
2353        Serialise this object into a string.
2354
2355        std::string Xapian::Query::serialise() const
2356        """
2357        return _xapian.Query_serialise(self)
2358
2359    unserialise = staticmethod(_xapian.Query_unserialise)
2360
2361    def get_type(self):
2362        """
2363
2364
2365        Get the type of the top level of the query.
2366
2367        op Xapian::Query::get_type() const
2368        """
2369        return _xapian.Query_get_type(self)
2370
2371
2372    def get_num_subqueries(self):
2373        """
2374
2375
2376        Get the number of subqueries of the top level query.
2377
2378        size_t Xapian::Query::get_num_subqueries() const
2379        """
2380        return _xapian.Query_get_num_subqueries(self)
2381
2382
2383    def get_subquery(self, n):
2384        """
2385
2386
2387        Read a top level subquery.
2388
2389        const Query Xapian::Query::get_subquery(size_t n) const
2390
2391        Parameters:
2392        -----------
2393
2394        n:  Return the n-th subquery (starting from 0) - only valid when 0 <=
2395        n < get_num_subqueries().
2396        """
2397        return _xapian.Query_get_subquery(self, n)
2398
2399
2400    def __str__(self):
2401        """
2402
2403
2404        Return a string describing this object.
2405
2406        std::string Xapian::Query::get_description() const
2407        """
2408        return _xapian.Query___str__(self)
2409
2410
2411    def __init__(self, *args):
2412        """
2413
2414
2415        Construct with just an operator.
2416
2417        Xapian::Query::Query(Query::op op_)
2418
2419        Parameters:
2420        -----------
2421
2422        op_:  The operator to use - currently only OP_INVALID is useful.
2423        """
2424        _xapian.Query_swiginit(self, _xapian.new_Query(*args))
2425Query._get_terms_begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.Query__get_terms_begin)
2426Query._get_terms_end = _xapian.SWIG_PyInstanceMethod_New(_xapian.Query__get_terms_end)
2427Query.get_unique_terms_begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.Query_get_unique_terms_begin)
2428Query.get_unique_terms_end = _xapian.SWIG_PyInstanceMethod_New(_xapian.Query_get_unique_terms_end)
2429Query.get_length = _xapian.SWIG_PyInstanceMethod_New(_xapian.Query_get_length)
2430Query.empty = _xapian.SWIG_PyInstanceMethod_New(_xapian.Query_empty)
2431Query.serialise = _xapian.SWIG_PyInstanceMethod_New(_xapian.Query_serialise)
2432Query.get_type = _xapian.SWIG_PyInstanceMethod_New(_xapian.Query_get_type)
2433Query.get_num_subqueries = _xapian.SWIG_PyInstanceMethod_New(_xapian.Query_get_num_subqueries)
2434Query.get_subquery = _xapian.SWIG_PyInstanceMethod_New(_xapian.Query_get_subquery)
2435Query.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.Query___str__)
2436Query_swigregister = _xapian.Query_swigregister
2437Query_swigregister(Query)
2438
2439def Query_unserialise(*args):
2440    return _xapian.Query_unserialise(*args)
2441Query_unserialise = _xapian.Query_unserialise
2442
2443class StemImplementation(object):
2444    """
2445
2446
2447    Class representing a stemming algorithm implementation.
2448    """
2449
2450    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
2451    __repr__ = _swig_repr
2452
2453    def __init__(self):
2454        """
2455
2456
2457        Default constructor.
2458
2459        Xapian::StemImplementation::StemImplementation()
2460        """
2461        if self.__class__ == StemImplementation:
2462            _self = None
2463        else:
2464            _self = self
2465        _xapian.StemImplementation_swiginit(self, _xapian.new_StemImplementation(_self, ))
2466    __swig_destroy__ = _xapian.delete_StemImplementation
2467
2468    def __str__(self):
2469        """
2470
2471
2472        Return a string describing this object.
2473
2474        virtual std::string Xapian::StemImplementation::get_description()
2475        const =0
2476        """
2477        return _xapian.StemImplementation___str__(self)
2478
2479    def __disown__(self):
2480        self.this.disown()
2481        _xapian.disown_StemImplementation(self)
2482        return weakref_proxy(self)
2483StemImplementation.__call__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.StemImplementation___call__)
2484StemImplementation.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.StemImplementation___str__)
2485StemImplementation_swigregister = _xapian.StemImplementation_swigregister
2486StemImplementation_swigregister(StemImplementation)
2487
2488class Stem(object):
2489    """
2490
2491
2492    Class representing a stemming algorithm.
2493    """
2494
2495    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
2496    __repr__ = _swig_repr
2497
2498    def __init__(self, *args):
2499        """
2500
2501
2502        Construct a Xapian::Stem object with a user-provided stemming
2503        algorithm.
2504
2505        Xapian::Stem::Stem(StemImplementation *p)
2506
2507        You can subclass Xapian::StemImplementation to implement your own
2508        stemming algorithm (or to wrap a third-party algorithm) and then wrap
2509        your implementation in a Xapian::Stem object to pass to the Xapian
2510        API.
2511
2512        Parameters:
2513        -----------
2514
2515        p:  The user-subclassed StemImplementation object. This is reference
2516        counted, and so will be automatically deleted by the Xapian::Stem
2517        wrapper when no longer required.
2518        """
2519        _xapian.Stem_swiginit(self, _xapian.new_Stem(*args))
2520    __swig_destroy__ = _xapian.delete_Stem
2521
2522    def is_none(self):
2523        """
2524
2525
2526        Return true if this is a no-op stemmer.
2527
2528        bool Xapian::Stem::is_none() const
2529        """
2530        return _xapian.Stem_is_none(self)
2531
2532
2533    def __str__(self):
2534        """
2535
2536
2537        Return a string describing this object.
2538
2539        std::string Xapian::Stem::get_description() const
2540        """
2541        return _xapian.Stem___str__(self)
2542
2543    get_available_languages = staticmethod(_xapian.Stem_get_available_languages)
2544Stem.__call__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.Stem___call__)
2545Stem.is_none = _xapian.SWIG_PyInstanceMethod_New(_xapian.Stem_is_none)
2546Stem.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.Stem___str__)
2547Stem_swigregister = _xapian.Stem_swigregister
2548Stem_swigregister(Stem)
2549
2550def Stem_get_available_languages():
2551    return _xapian.Stem_get_available_languages()
2552Stem_get_available_languages = _xapian.Stem_get_available_languages
2553
2554class TermGenerator(object):
2555    """
2556
2557
2558    Parses a piece of text and generate terms.
2559
2560    This module takes a piece of text and parses it to produce words which
2561    are then used to generate suitable terms for indexing. The terms
2562    generated are suitable for use with Query objects produced by the
2563    QueryParser class.
2564    """
2565
2566    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
2567    __repr__ = _swig_repr
2568
2569    def __init__(self):
2570        """
2571
2572
2573        Default constructor.
2574
2575        Xapian::TermGenerator::TermGenerator()
2576        """
2577        _xapian.TermGenerator_swiginit(self, _xapian.new_TermGenerator())
2578    __swig_destroy__ = _xapian.delete_TermGenerator
2579
2580    def set_stemmer(self, stemmer):
2581        """
2582
2583
2584        Set the Xapian::Stem object to be used for generating stemmed terms.
2585
2586        void Xapian::TermGenerator::set_stemmer(const Xapian::Stem &stemmer)
2587
2588        """
2589        return _xapian.TermGenerator_set_stemmer(self, stemmer)
2590
2591
2592    def set_stopper(self, stop=None):
2593        """
2594
2595
2596        Set the Xapian::Stopper object to be used for identifying stopwords.
2597
2598        void Xapian::TermGenerator::set_stopper(const Xapian::Stopper
2599        *stop=NULL)
2600
2601        Stemmed forms of stopwords aren't indexed, but unstemmed forms still
2602        are so that searches for phrases including stop words still work.
2603
2604        Parameters:
2605        -----------
2606
2607        stop:  The Stopper object to set (default NULL, which means no
2608        stopwords).
2609        """
2610        return _xapian.TermGenerator_set_stopper(self, stop)
2611
2612
2613    def set_document(self, doc):
2614        """
2615
2616
2617        Set the current document.
2618
2619        void Xapian::TermGenerator::set_document(const Xapian::Document &doc)
2620
2621        """
2622        return _xapian.TermGenerator_set_document(self, doc)
2623
2624
2625    def get_document(self):
2626        """
2627
2628
2629        Get the current document.
2630
2631        const Xapian::Document& Xapian::TermGenerator::get_document() const
2632        """
2633        return _xapian.TermGenerator_get_document(self)
2634
2635
2636    def set_database(self, db):
2637        """
2638
2639
2640        Set the database to index spelling data to.
2641
2642        void Xapian::TermGenerator::set_database(const
2643        Xapian::WritableDatabase &db)
2644        """
2645        return _xapian.TermGenerator_set_database(self, db)
2646
2647    FLAG_SPELLING = _xapian.TermGenerator_FLAG_SPELLING
2648    FLAG_CJK_NGRAM = _xapian.TermGenerator_FLAG_CJK_NGRAM
2649    STEM_NONE = _xapian.TermGenerator_STEM_NONE
2650    STEM_SOME = _xapian.TermGenerator_STEM_SOME
2651    STEM_ALL = _xapian.TermGenerator_STEM_ALL
2652    STEM_ALL_Z = _xapian.TermGenerator_STEM_ALL_Z
2653    STEM_SOME_FULL_POS = _xapian.TermGenerator_STEM_SOME_FULL_POS
2654    STOP_NONE = _xapian.TermGenerator_STOP_NONE
2655    STOP_ALL = _xapian.TermGenerator_STOP_ALL
2656    STOP_STEMMED = _xapian.TermGenerator_STOP_STEMMED
2657
2658    def set_flags(self, *args):
2659        """
2660
2661
2662        Set flags.
2663
2664        flags Xapian::TermGenerator::set_flags(flags toggle, flags
2665        mask=flags(0))
2666
2667        The new value of flags is: (flags & mask) ^ toggle
2668
2669        To just set the flags, pass the new flags in toggle and the default
2670        value for mask.
2671
2672        Parameters:
2673        -----------
2674
2675        toggle:  Flags to XOR.
2676
2677        mask:  Flags to AND with first.
2678
2679        The old flags setting.
2680        """
2681        return _xapian.TermGenerator_set_flags(self, *args)
2682
2683
2684    def set_stemming_strategy(self, strategy):
2685        """
2686
2687
2688        Set the stemming strategy.
2689
2690        void Xapian::TermGenerator::set_stemming_strategy(stem_strategy
2691        strategy)
2692
2693        This method controls how the stemming algorithm is applied. It was new
2694        in Xapian 1.3.1.
2695
2696        Parameters:
2697        -----------
2698
2699        strategy:  The strategy to use - possible values are: STEM_NONE: Don't
2700        perform any stemming - only unstemmed terms are generated.
2701
2702        STEM_SOME: Generate both stemmed (with a "Z" prefix) and unstemmed
2703        terms. No positional information is stored for unstemmed terms. This
2704        is the default strategy.
2705
2706        STEM_SOME_FULL_POS: Like STEM_SOME but positional information is
2707        stored for both stemmed and unstemmed terms. Added in Xapian 1.4.8.
2708
2709        STEM_ALL: Generate only stemmed terms (but without a "Z" prefix).
2710
2711        STEM_ALL_Z: Generate only stemmed terms (with a "Z" prefix).
2712        """
2713        return _xapian.TermGenerator_set_stemming_strategy(self, strategy)
2714
2715
2716    def set_stopper_strategy(self, strategy):
2717        """
2718
2719
2720        Set the stopper strategy.
2721
2722        void Xapian::TermGenerator::set_stopper_strategy(stop_strategy
2723        strategy)
2724
2725        The method controls how the stopper is used. It was added in Xapian
2726        1.4.1.
2727
2728        You need to also call  set_stopper() for this to have any effect.
2729
2730        Parameters:
2731        -----------
2732
2733        strategy:  The strategy to use - possible values are: STOP_NONE: Don't
2734        use the stopper.
2735
2736        STOP_ALL: If a word is identified as a stop word, skip it completely.
2737
2738        STOP_STEMMED: If a word is identified as a stop word, index its
2739        unstemmed form but skip the stem. Unstemmed forms are indexed with
2740        positional information by default, so this allows searches for phrases
2741        containing stopwords to be supported. (This is the default mode).
2742        """
2743        return _xapian.TermGenerator_set_stopper_strategy(self, strategy)
2744
2745
2746    def set_max_word_length(self, max_word_length):
2747        """
2748
2749
2750        Set the maximum length word to index.
2751
2752        void Xapian::TermGenerator::set_max_word_length(unsigned
2753        max_word_length)
2754
2755        The limit is on the length of a word prior to stemming and prior to
2756        adding any term prefix.
2757
2758        The backends mostly impose a limit on the length of terms (often of
2759        about 240 bytes), but it's generally useful to have a lower limit to
2760        help prevent the index being bloated by useless junk terms from trying
2761        to indexing things like binary data, uuencoded data, ASCII art, etc.
2762
2763        This method was new in Xapian 1.3.1.
2764
2765        Parameters:
2766        -----------
2767
2768        max_word_length:  The maximum length word to index, in bytes in UTF-8
2769        representation. Default is 64.
2770        """
2771        return _xapian.TermGenerator_set_max_word_length(self, max_word_length)
2772
2773
2774    def index_text(self, *args):
2775        """
2776
2777
2778        Index some text in a std::string.
2779
2780        void Xapian::TermGenerator::index_text(const std::string &text,
2781        Xapian::termcount wdf_inc=1, const std::string &prefix=std::string())
2782
2783        Parameters:
2784        -----------
2785
2786        text:  The text to index.
2787
2788        wdf_inc:  The wdf increment (default 1).
2789
2790        prefix:  The term prefix to use (default is no prefix).
2791        """
2792        return _xapian.TermGenerator_index_text(self, *args)
2793
2794
2795    def index_text_without_positions(self, *args):
2796        """
2797
2798
2799        Index some text in a std::string without positional information.
2800
2801        void Xapian::TermGenerator::index_text_without_positions(const
2802        std::string &text, Xapian::termcount wdf_inc=1, const std::string
2803        &prefix=std::string())
2804
2805        Just like index_text, but no positional information is generated. This
2806        means that the database will be significantly smaller, but that phrase
2807        searching and NEAR won't be supported.
2808
2809        Parameters:
2810        -----------
2811
2812        text:  The text to index.
2813
2814        wdf_inc:  The wdf increment (default 1).
2815
2816        prefix:  The term prefix to use (default is no prefix).
2817        """
2818        return _xapian.TermGenerator_index_text_without_positions(self, *args)
2819
2820
2821    def increase_termpos(self, delta=100):
2822        """
2823
2824
2825        Increase the term position used by index_text.
2826
2827        void Xapian::TermGenerator::increase_termpos(Xapian::termpos
2828        delta=100)
2829
2830        This can be used between indexing text from different fields or other
2831        places to prevent phrase searches from spanning between them (e.g.
2832        between the title and body text, or between two chapters in a book).
2833
2834        Parameters:
2835        -----------
2836
2837        delta:  Amount to increase the term position by (default: 100).
2838        """
2839        return _xapian.TermGenerator_increase_termpos(self, delta)
2840
2841
2842    def get_termpos(self):
2843        """
2844
2845
2846        Get the current term position.
2847
2848        Xapian::termpos Xapian::TermGenerator::get_termpos() const
2849        """
2850        return _xapian.TermGenerator_get_termpos(self)
2851
2852
2853    def set_termpos(self, termpos):
2854        """
2855
2856
2857        Set the current term position.
2858
2859        void Xapian::TermGenerator::set_termpos(Xapian::termpos termpos)
2860
2861        Parameters:
2862        -----------
2863
2864        termpos:  The new term position to set.
2865        """
2866        return _xapian.TermGenerator_set_termpos(self, termpos)
2867
2868
2869    def __str__(self):
2870        """
2871
2872
2873        Return a string describing this object.
2874
2875        std::string Xapian::TermGenerator::get_description() const
2876        """
2877        return _xapian.TermGenerator___str__(self)
2878
2879TermGenerator.set_stemmer = _xapian.SWIG_PyInstanceMethod_New(_xapian.TermGenerator_set_stemmer)
2880TermGenerator.set_stopper = _xapian.SWIG_PyInstanceMethod_New(_xapian.TermGenerator_set_stopper)
2881TermGenerator.set_document = _xapian.SWIG_PyInstanceMethod_New(_xapian.TermGenerator_set_document)
2882TermGenerator.get_document = _xapian.SWIG_PyInstanceMethod_New(_xapian.TermGenerator_get_document)
2883TermGenerator.set_database = _xapian.SWIG_PyInstanceMethod_New(_xapian.TermGenerator_set_database)
2884TermGenerator.set_flags = _xapian.SWIG_PyInstanceMethod_New(_xapian.TermGenerator_set_flags)
2885TermGenerator.set_stemming_strategy = _xapian.SWIG_PyInstanceMethod_New(_xapian.TermGenerator_set_stemming_strategy)
2886TermGenerator.set_stopper_strategy = _xapian.SWIG_PyInstanceMethod_New(_xapian.TermGenerator_set_stopper_strategy)
2887TermGenerator.set_max_word_length = _xapian.SWIG_PyInstanceMethod_New(_xapian.TermGenerator_set_max_word_length)
2888TermGenerator.index_text = _xapian.SWIG_PyInstanceMethod_New(_xapian.TermGenerator_index_text)
2889TermGenerator.index_text_without_positions = _xapian.SWIG_PyInstanceMethod_New(_xapian.TermGenerator_index_text_without_positions)
2890TermGenerator.increase_termpos = _xapian.SWIG_PyInstanceMethod_New(_xapian.TermGenerator_increase_termpos)
2891TermGenerator.get_termpos = _xapian.SWIG_PyInstanceMethod_New(_xapian.TermGenerator_get_termpos)
2892TermGenerator.set_termpos = _xapian.SWIG_PyInstanceMethod_New(_xapian.TermGenerator_set_termpos)
2893TermGenerator.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.TermGenerator___str__)
2894TermGenerator_swigregister = _xapian.TermGenerator_swigregister
2895TermGenerator_swigregister(TermGenerator)
2896
2897class MSet(object):
2898    """
2899
2900
2901    Class representing a list of search results.
2902    """
2903
2904    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
2905    __repr__ = _swig_repr
2906
2907    def __init__(self):
2908        """
2909
2910
2911        Default constructor.
2912
2913        Xapian::MSet::MSet()
2914
2915        Creates an empty MSet, mostly useful as a placeholder.
2916        """
2917        _xapian.MSet_swiginit(self, _xapian.new_MSet())
2918    __swig_destroy__ = _xapian.delete_MSet
2919
2920    def convert_to_percent(self, *args):
2921        """
2922
2923
2924        Convert the weight of the current iterator position to a percentage.
2925
2926        int Xapian::MSet::convert_to_percent(const MSetIterator &it) const
2927
2928        The matching document with the highest weight will get 100% if it
2929        matches all the weighted query terms, and proportionally less if it
2930        only matches some, and other weights are scaled by the same factor.
2931
2932        Documents with a non-zero score will always score at least 1%.
2933
2934        Note that these generally aren't percentages of anything meaningful
2935        (unless you use a custom weighting formula where they are!)
2936        """
2937        return _xapian.MSet_convert_to_percent(self, *args)
2938
2939
2940    def get_termfreq(self, term):
2941        """
2942
2943
2944        Get the termfreq of a term.
2945
2946        Xapian::doccount Xapian::MSet::get_termfreq(const std::string &term)
2947        const
2948
2949        The number of documents which term occurs in. This considers all
2950        documents in the database being searched, so gives the same answer as
2951        db.get_termfreq(term) (but is more efficient for query terms as it
2952        returns a value cached during the search.)
2953        """
2954        return _xapian.MSet_get_termfreq(self, term)
2955
2956
2957    def get_termweight(self, term):
2958        """
2959
2960
2961        Get the term weight of a term.
2962
2963        double Xapian::MSet::get_termweight(const std::string &term) const
2964
2965        The maximum weight that term could have contributed to a document.
2966        """
2967        return _xapian.MSet_get_termweight(self, term)
2968
2969
2970    def get_firstitem(self):
2971        """
2972
2973
2974        Rank of first item in this MSet.
2975
2976        Xapian::doccount Xapian::MSet::get_firstitem() const
2977
2978        This is the parameter first passed to Xapian::Enquire::get_mset().
2979        """
2980        return _xapian.MSet_get_firstitem(self)
2981
2982
2983    def get_matches_lower_bound(self):
2984        """
2985
2986
2987        Lower bound on the total number of matching documents.
2988
2989        Xapian::doccount Xapian::MSet::get_matches_lower_bound() const
2990        """
2991        return _xapian.MSet_get_matches_lower_bound(self)
2992
2993
2994    def get_matches_estimated(self):
2995        """
2996
2997
2998        Estimate of the total number of matching documents.
2999
3000        Xapian::doccount Xapian::MSet::get_matches_estimated() const
3001        """
3002        return _xapian.MSet_get_matches_estimated(self)
3003
3004
3005    def get_matches_upper_bound(self):
3006        """
3007
3008
3009        Upper bound on the total number of matching documents.
3010
3011        Xapian::doccount Xapian::MSet::get_matches_upper_bound() const
3012        """
3013        return _xapian.MSet_get_matches_upper_bound(self)
3014
3015
3016    def get_uncollapsed_matches_lower_bound(self):
3017        """
3018
3019
3020        Lower bound on the total number of matching documents before
3021        collapsing.
3022
3023        Xapian::doccount Xapian::MSet::get_uncollapsed_matches_lower_bound()
3024        const
3025
3026        Conceptually the same as get_matches_lower_bound() for the same query
3027        without any collapse part (though the actual value may differ).
3028        """
3029        return _xapian.MSet_get_uncollapsed_matches_lower_bound(self)
3030
3031
3032    def get_uncollapsed_matches_estimated(self):
3033        """
3034
3035
3036        Estimate of the total number of matching documents before collapsing.
3037
3038        Xapian::doccount Xapian::MSet::get_uncollapsed_matches_estimated()
3039        const
3040
3041        Conceptually the same as get_matches_estimated() for the same query
3042        without any collapse part (though the actual value may differ).
3043        """
3044        return _xapian.MSet_get_uncollapsed_matches_estimated(self)
3045
3046
3047    def get_uncollapsed_matches_upper_bound(self):
3048        """
3049
3050
3051        Upper bound on the total number of matching documents before
3052        collapsing.
3053
3054        Xapian::doccount Xapian::MSet::get_uncollapsed_matches_upper_bound()
3055        const
3056
3057        Conceptually the same as get_matches_upper_bound() for the same query
3058        without any collapse part (though the actual value may differ).
3059        """
3060        return _xapian.MSet_get_uncollapsed_matches_upper_bound(self)
3061
3062
3063    def get_max_attained(self):
3064        """
3065
3066
3067        The maximum weight attained by any document.
3068
3069        double Xapian::MSet::get_max_attained() const
3070        """
3071        return _xapian.MSet_get_max_attained(self)
3072
3073
3074    def get_max_possible(self):
3075        """
3076
3077
3078        The maximum possible weight any document could achieve.
3079
3080        double Xapian::MSet::get_max_possible() const
3081        """
3082        return _xapian.MSet_get_max_possible(self)
3083
3084    SNIPPET_BACKGROUND_MODEL = _xapian.MSet_SNIPPET_BACKGROUND_MODEL
3085    SNIPPET_EXHAUSTIVE = _xapian.MSet_SNIPPET_EXHAUSTIVE
3086    SNIPPET_EMPTY_WITHOUT_MATCH = _xapian.MSet_SNIPPET_EMPTY_WITHOUT_MATCH
3087    SNIPPET_CJK_NGRAM = _xapian.MSet_SNIPPET_CJK_NGRAM
3088
3089    def snippet(self, *args):
3090        """
3091
3092
3093        Generate a snippet.
3094
3095        std::string Xapian::MSet::snippet(const std::string &text, size_t
3096        length=500, const Xapian::Stem &stemmer=Xapian::Stem(), unsigned
3097        flags=SNIPPET_BACKGROUND_MODEL|SNIPPET_EXHAUSTIVE, const std::string
3098        &hi_start="<b>", const std::string &hi_end="</b>", const
3099        std::string &omit="...") const
3100
3101        This method selects a continuous run of words from text, based mainly
3102        on where the query matches (currently terms, exact phrases and
3103        wildcards are taken into account). If flag SNIPPET_BACKGROUND_MODEL is
3104        used (which it is by default) then the selection algorithm also
3105        considers the non-query terms in the text with the aim of showing a
3106        context which provides more useful information.
3107
3108        The size of the text selected can be controlled by the length
3109        parameter, which specifies a number of bytes of text to aim to select.
3110        However slightly more text may be selected. Also the size of any
3111        escaping, highlighting or omission markers is not considered.
3112
3113        The returned text is escaped to make it suitable for use in HTML
3114        (though beware that in upstream releases 1.4.5 and earlier this
3115        escaping was sometimes incomplete), and matches with the query will be
3116        highlighted using hi_start and hi_end.
3117
3118        If the snippet seems to start or end mid-sentence, then omit is
3119        prepended or append (respectively) to indicate this.
3120
3121        The same stemming algorithm which was used to build the query should
3122        be specified in stemmer.
3123
3124        And flags contains flags controlling behaviour.
3125
3126        Added in 1.3.5.
3127        """
3128        return _xapian.MSet_snippet(self, *args)
3129
3130
3131    def fetch(self, *args):
3132        """
3133
3134
3135        Prefetch hint the whole MSet.
3136
3137        void Xapian::MSet::fetch() const
3138
3139        For a remote database, this may start a pipelined fetch of the
3140        requested documents from the remote server.
3141
3142        For a disk-based database, this may send prefetch hints to the
3143        operating system such that the disk blocks the requested documents are
3144        stored in are more likely to be in the cache when we come to actually
3145        read them.
3146        """
3147        return _xapian.MSet_fetch(self, *args)
3148
3149
3150    def size(self):
3151        """
3152
3153
3154        Return number of items in this MSet object.
3155
3156        Xapian::doccount Xapian::MSet::size() const
3157        """
3158        return _xapian.MSet_size(self)
3159
3160
3161    def empty(self):
3162        """
3163
3164
3165        Return true if this MSet object is empty.
3166
3167        bool Xapian::MSet::empty() const
3168        """
3169        return _xapian.MSet_empty(self)
3170
3171
3172    def _begin(self):
3173        """
3174
3175
3176        Return iterator pointing to the first item in this MSet.
3177
3178        MSetIterator Xapian::MSet::begin() const
3179        """
3180        return _xapian.MSet__begin(self)
3181
3182
3183    def _end(self):
3184        """
3185
3186
3187        Return iterator pointing to just after the last item in this MSet.
3188
3189        MSetIterator Xapian::MSet::end() const
3190        """
3191        return _xapian.MSet__end(self)
3192
3193
3194    def back(self):
3195        """
3196
3197
3198        Return iterator pointing to the last object in this MSet.
3199
3200        MSetIterator Xapian::MSet::back() const
3201        """
3202        return _xapian.MSet_back(self)
3203
3204
3205    def __str__(self):
3206        """
3207
3208
3209        Return a string describing this object.
3210
3211        std::string Xapian::MSet::get_description() const
3212        """
3213        return _xapian.MSet___str__(self)
3214
3215
3216    def _get_hit_internal(self, i):
3217        """
3218        Get an item from the MSet.
3219
3220        The supplied index is relative to the start of the MSet, not the absolute rank
3221        of the item.
3222        """
3223        return _xapian.MSet__get_hit_internal(self, i)
3224
3225MSet.convert_to_percent = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet_convert_to_percent)
3226MSet.get_termfreq = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet_get_termfreq)
3227MSet.get_termweight = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet_get_termweight)
3228MSet.get_firstitem = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet_get_firstitem)
3229MSet.get_matches_lower_bound = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet_get_matches_lower_bound)
3230MSet.get_matches_estimated = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet_get_matches_estimated)
3231MSet.get_matches_upper_bound = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet_get_matches_upper_bound)
3232MSet.get_uncollapsed_matches_lower_bound = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet_get_uncollapsed_matches_lower_bound)
3233MSet.get_uncollapsed_matches_estimated = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet_get_uncollapsed_matches_estimated)
3234MSet.get_uncollapsed_matches_upper_bound = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet_get_uncollapsed_matches_upper_bound)
3235MSet.get_max_attained = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet_get_max_attained)
3236MSet.get_max_possible = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet_get_max_possible)
3237MSet.snippet = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet_snippet)
3238MSet.fetch = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet_fetch)
3239MSet.size = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet_size)
3240MSet.empty = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet_empty)
3241MSet._begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet__begin)
3242MSet._end = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet__end)
3243MSet.back = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet_back)
3244MSet.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet___str__)
3245MSet.get_docid = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet_get_docid)
3246MSet.get_document = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet_get_document)
3247MSet._get_hit_internal = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet__get_hit_internal)
3248MSet.get_document_percentage = _xapian.SWIG_PyInstanceMethod_New(_xapian.MSet_get_document_percentage)
3249MSet_swigregister = _xapian.MSet_swigregister
3250MSet_swigregister(MSet)
3251
3252class _MSetIterator(object):
3253    """
3254
3255
3256    Iterator over a Xapian::MSet.
3257    """
3258
3259    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
3260    __repr__ = _swig_repr
3261    mset = property(_xapian._MSetIterator_mset_get, _xapian._MSetIterator_mset_set)
3262    off_from_end = property(_xapian._MSetIterator_off_from_end_get, _xapian._MSetIterator_off_from_end_set)
3263
3264    def __init__(self):
3265        """
3266
3267
3268        Create an unpositioned MSetIterator.
3269
3270        Xapian::MSetIterator::MSetIterator()
3271        """
3272        _xapian._MSetIterator_swiginit(self, _xapian.new__MSetIterator())
3273
3274    def get_rank(self):
3275        """
3276
3277
3278        Return the MSet rank for the current position.
3279
3280        Xapian::doccount Xapian::MSetIterator::get_rank() const
3281
3282        The rank of mset[0] is mset.get_firstitem().
3283        """
3284        return _xapian._MSetIterator_get_rank(self)
3285
3286
3287    def get_document(self):
3288        """
3289
3290
3291        Get the Document object for the current position.
3292
3293        Xapian::Document Xapian::MSetIterator::get_document() const
3294        """
3295        return _xapian._MSetIterator_get_document(self)
3296
3297
3298    def get_weight(self):
3299        """
3300
3301
3302        Get the weight for the current position.
3303
3304        double Xapian::MSetIterator::get_weight() const
3305        """
3306        return _xapian._MSetIterator_get_weight(self)
3307
3308
3309    def get_collapse_key(self):
3310        """
3311
3312
3313        Return the collapse key for the current position.
3314
3315        std::string Xapian::MSetIterator::get_collapse_key() const
3316
3317        If collapsing isn't in use, an empty string will be returned.
3318        """
3319        return _xapian._MSetIterator_get_collapse_key(self)
3320
3321
3322    def get_collapse_count(self):
3323        """
3324
3325
3326        Return a count of the number of collapses done onto the current key.
3327
3328        Xapian::doccount Xapian::MSetIterator::get_collapse_count() const
3329
3330        This starts at 0, and is incremented each time an item is eliminated
3331        because its key is the same as that of the current item (as returned
3332        by get_collapse_key()).
3333
3334        Note that this is NOT necessarily one less than the total number of
3335        matching documents with this collapse key due to various optimisations
3336        implemented in the matcher - for example, it can skip documents
3337        completely if it can prove their weight wouldn't be enough to make the
3338        result set.
3339
3340        You can say is that if get_collapse_count() > 0 then there are >=
3341        get_collapse_count() other documents with the current collapse key.
3342        But if get_collapse_count() == 0 then there may or may not be other
3343        such documents.
3344        """
3345        return _xapian._MSetIterator_get_collapse_count(self)
3346
3347
3348    def get_sort_key(self):
3349        """
3350
3351
3352        Return the sort key for the current position.
3353
3354        std::string Xapian::MSetIterator::get_sort_key() const
3355
3356        If sorting didn't use a key then an empty string will be returned.
3357
3358        Added in Xapian 1.4.6.
3359        """
3360        return _xapian._MSetIterator_get_sort_key(self)
3361
3362
3363    def get_percent(self):
3364        """
3365
3366
3367        Convert the weight of the current iterator position to a percentage.
3368
3369        int Xapian::MSetIterator::get_percent() const
3370
3371        The matching document with the highest weight will get 100% if it
3372        matches all the weighted query terms, and proportionally less if it
3373        only matches some, and other weights are scaled by the same factor.
3374
3375        Documents with a non-zero score will always score at least 1%.
3376
3377        Note that these generally aren't percentages of anything meaningful
3378        (unless you use a custom weighting formula where they are!)
3379        """
3380        return _xapian._MSetIterator_get_percent(self)
3381
3382
3383    def __str__(self):
3384        """
3385
3386
3387        Return a string describing this object.
3388
3389        std::string Xapian::MSetIterator::get_description() const
3390        """
3391        return _xapian._MSetIterator___str__(self)
3392
3393    __swig_destroy__ = _xapian.delete__MSetIterator
3394_MSetIterator.get_rank = _xapian.SWIG_PyInstanceMethod_New(_xapian._MSetIterator_get_rank)
3395_MSetIterator.get_document = _xapian.SWIG_PyInstanceMethod_New(_xapian._MSetIterator_get_document)
3396_MSetIterator.get_weight = _xapian.SWIG_PyInstanceMethod_New(_xapian._MSetIterator_get_weight)
3397_MSetIterator.get_collapse_key = _xapian.SWIG_PyInstanceMethod_New(_xapian._MSetIterator_get_collapse_key)
3398_MSetIterator.get_collapse_count = _xapian.SWIG_PyInstanceMethod_New(_xapian._MSetIterator_get_collapse_count)
3399_MSetIterator.get_sort_key = _xapian.SWIG_PyInstanceMethod_New(_xapian._MSetIterator_get_sort_key)
3400_MSetIterator.get_percent = _xapian.SWIG_PyInstanceMethod_New(_xapian._MSetIterator_get_percent)
3401_MSetIterator.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._MSetIterator___str__)
3402_MSetIterator.__eq__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._MSetIterator___eq__)
3403_MSetIterator.__ne__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._MSetIterator___ne__)
3404_MSetIterator.equals = _xapian.SWIG_PyInstanceMethod_New(_xapian._MSetIterator_equals)
3405_MSetIterator.get_docid = _xapian.SWIG_PyInstanceMethod_New(_xapian._MSetIterator_get_docid)
3406_MSetIterator.__next__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._MSetIterator___next__)
3407_MSetIterator.prev = _xapian.SWIG_PyInstanceMethod_New(_xapian._MSetIterator_prev)
3408_MSetIterator_swigregister = _xapian._MSetIterator_swigregister
3409_MSetIterator_swigregister(_MSetIterator)
3410
3411class ESet(object):
3412    """
3413
3414
3415    Class representing a list of search results.
3416    """
3417
3418    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
3419    __repr__ = _swig_repr
3420
3421    def __init__(self):
3422        """
3423
3424
3425        Default constructor.
3426
3427        Xapian::ESet::ESet()
3428
3429        Creates an empty ESet, mostly useful as a placeholder.
3430        """
3431        _xapian.ESet_swiginit(self, _xapian.new_ESet())
3432    __swig_destroy__ = _xapian.delete_ESet
3433
3434    def size(self):
3435        """
3436
3437
3438        Return number of items in this ESet object.
3439
3440        Xapian::doccount Xapian::ESet::size() const
3441        """
3442        return _xapian.ESet_size(self)
3443
3444
3445    def empty(self):
3446        """
3447
3448
3449        Return true if this ESet object is empty.
3450
3451        bool Xapian::ESet::empty() const
3452        """
3453        return _xapian.ESet_empty(self)
3454
3455
3456    def get_ebound(self):
3457        """
3458
3459
3460        Return a bound on the full size of this ESet object.
3461
3462        Xapian::termcount Xapian::ESet::get_ebound() const
3463
3464        This is a bound on size() if get_eset() had been called with maxitems
3465        set high enough that all results were returned.
3466        """
3467        return _xapian.ESet_get_ebound(self)
3468
3469
3470    def _begin(self):
3471        """
3472
3473
3474        Return iterator pointing to the first item in this ESet.
3475
3476        ESetIterator Xapian::ESet::begin() const
3477        """
3478        return _xapian.ESet__begin(self)
3479
3480
3481    def _end(self):
3482        """
3483
3484
3485        Return iterator pointing to just after the last item in this ESet.
3486
3487        ESetIterator Xapian::ESet::end() const
3488        """
3489        return _xapian.ESet__end(self)
3490
3491
3492    def back(self):
3493        """
3494
3495
3496        Return iterator pointing to the last object in this ESet.
3497
3498        ESetIterator Xapian::ESet::back() const
3499        """
3500        return _xapian.ESet_back(self)
3501
3502
3503    def __str__(self):
3504        """
3505
3506
3507        Return a string describing this object.
3508
3509        std::string Xapian::ESet::get_description() const
3510        """
3511        return _xapian.ESet___str__(self)
3512
3513ESet.size = _xapian.SWIG_PyInstanceMethod_New(_xapian.ESet_size)
3514ESet.empty = _xapian.SWIG_PyInstanceMethod_New(_xapian.ESet_empty)
3515ESet.get_ebound = _xapian.SWIG_PyInstanceMethod_New(_xapian.ESet_get_ebound)
3516ESet._begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.ESet__begin)
3517ESet._end = _xapian.SWIG_PyInstanceMethod_New(_xapian.ESet__end)
3518ESet.back = _xapian.SWIG_PyInstanceMethod_New(_xapian.ESet_back)
3519ESet.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.ESet___str__)
3520ESet_swigregister = _xapian.ESet_swigregister
3521ESet_swigregister(ESet)
3522
3523class _ESetIterator(object):
3524    """
3525
3526
3527    Iterator over a Xapian::ESet.
3528    """
3529
3530    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
3531    __repr__ = _swig_repr
3532    eset = property(_xapian._ESetIterator_eset_get, _xapian._ESetIterator_eset_set)
3533    off_from_end = property(_xapian._ESetIterator_off_from_end_get, _xapian._ESetIterator_off_from_end_set)
3534
3535    def __init__(self):
3536        """
3537
3538
3539        Create an unpositioned ESetIterator.
3540
3541        Xapian::ESetIterator::ESetIterator()
3542        """
3543        _xapian._ESetIterator_swiginit(self, _xapian.new__ESetIterator())
3544
3545    def get_weight(self):
3546        """
3547
3548
3549        Get the weight for the current position.
3550
3551        double Xapian::ESetIterator::get_weight() const
3552        """
3553        return _xapian._ESetIterator_get_weight(self)
3554
3555
3556    def __str__(self):
3557        """
3558
3559
3560        Return a string describing this object.
3561
3562        std::string Xapian::ESetIterator::get_description() const
3563        """
3564        return _xapian._ESetIterator___str__(self)
3565
3566    __swig_destroy__ = _xapian.delete__ESetIterator
3567_ESetIterator.get_weight = _xapian.SWIG_PyInstanceMethod_New(_xapian._ESetIterator_get_weight)
3568_ESetIterator.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._ESetIterator___str__)
3569_ESetIterator.__eq__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._ESetIterator___eq__)
3570_ESetIterator.__ne__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._ESetIterator___ne__)
3571_ESetIterator.equals = _xapian.SWIG_PyInstanceMethod_New(_xapian._ESetIterator_equals)
3572_ESetIterator.get_term = _xapian.SWIG_PyInstanceMethod_New(_xapian._ESetIterator_get_term)
3573_ESetIterator.__next__ = _xapian.SWIG_PyInstanceMethod_New(_xapian._ESetIterator___next__)
3574_ESetIterator.prev = _xapian.SWIG_PyInstanceMethod_New(_xapian._ESetIterator_prev)
3575_ESetIterator_swigregister = _xapian._ESetIterator_swigregister
3576_ESetIterator_swigregister(_ESetIterator)
3577
3578
3579def __eq__(*args):
3580    return _xapian.__eq__(*args)
3581__eq__ = _xapian.__eq__
3582
3583def __lt__(*args):
3584    return _xapian.__lt__(*args)
3585__lt__ = _xapian.__lt__
3586
3587def __gt__(*args):
3588    return _xapian.__gt__(*args)
3589__gt__ = _xapian.__gt__
3590
3591def __ge__(*args):
3592    return _xapian.__ge__(*args)
3593__ge__ = _xapian.__ge__
3594
3595def __le__(*args):
3596    return _xapian.__le__(*args)
3597__le__ = _xapian.__le__
3598
3599def __add__(*args):
3600    return _xapian.__add__(*args)
3601__add__ = _xapian.__add__
3602class RSet(object):
3603    """
3604
3605
3606    A relevance set (R-Set).
3607
3608    This is the set of documents which are marked as relevant, for use in
3609    modifying the term weights, and in performing query expansion.
3610    """
3611
3612    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
3613    __repr__ = _swig_repr
3614
3615    def __init__(self):
3616        """
3617
3618
3619        Default constructor.
3620
3621        Xapian::RSet::RSet()
3622        """
3623        _xapian.RSet_swiginit(self, _xapian.new_RSet())
3624    __swig_destroy__ = _xapian.delete_RSet
3625
3626    def size(self):
3627        """
3628
3629
3630        The number of documents in this R-Set.
3631
3632        Xapian::doccount Xapian::RSet::size() const
3633        """
3634        return _xapian.RSet_size(self)
3635
3636
3637    def empty(self):
3638        """
3639
3640
3641        Test if this R-Set is empty.
3642
3643        bool Xapian::RSet::empty() const
3644        """
3645        return _xapian.RSet_empty(self)
3646
3647
3648    def add_document(self, *args):
3649        """
3650
3651
3652        Add a document to the relevance set.
3653
3654        void Xapian::RSet::add_document(const Xapian::MSetIterator &i)
3655        """
3656        return _xapian.RSet_add_document(self, *args)
3657
3658
3659    def remove_document(self, *args):
3660        """
3661
3662
3663        Remove a document from the relevance set.
3664
3665        void Xapian::RSet::remove_document(const Xapian::MSetIterator &i)
3666        """
3667        return _xapian.RSet_remove_document(self, *args)
3668
3669
3670    def contains(self, *args):
3671        """
3672
3673
3674        Test if a given document in the relevance set.
3675
3676        bool Xapian::RSet::contains(const Xapian::MSetIterator &i) const
3677        """
3678        return _xapian.RSet_contains(self, *args)
3679
3680
3681    def __str__(self):
3682        """
3683
3684
3685        Return a string describing this object.
3686
3687        std::string Xapian::RSet::get_description() const
3688        """
3689        return _xapian.RSet___str__(self)
3690
3691RSet.size = _xapian.SWIG_PyInstanceMethod_New(_xapian.RSet_size)
3692RSet.empty = _xapian.SWIG_PyInstanceMethod_New(_xapian.RSet_empty)
3693RSet.add_document = _xapian.SWIG_PyInstanceMethod_New(_xapian.RSet_add_document)
3694RSet.remove_document = _xapian.SWIG_PyInstanceMethod_New(_xapian.RSet_remove_document)
3695RSet.contains = _xapian.SWIG_PyInstanceMethod_New(_xapian.RSet_contains)
3696RSet.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.RSet___str__)
3697RSet_swigregister = _xapian.RSet_swigregister
3698RSet_swigregister(RSet)
3699
3700class MatchDecider(object):
3701    """
3702
3703
3704    Base class for matcher decision functor.
3705    """
3706
3707    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
3708    __repr__ = _swig_repr
3709
3710    def __init__(self):
3711        """
3712
3713
3714        Default constructor.
3715
3716        Xapian::MatchDecider::MatchDecider()
3717        """
3718        if self.__class__ == MatchDecider:
3719            _self = None
3720        else:
3721            _self = self
3722        _xapian.MatchDecider_swiginit(self, _xapian.new_MatchDecider(_self, ))
3723    __swig_destroy__ = _xapian.delete_MatchDecider
3724    def __disown__(self):
3725        self.this.disown()
3726        _xapian.disown_MatchDecider(self)
3727        return weakref_proxy(self)
3728MatchDecider.__call__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.MatchDecider___call__)
3729MatchDecider_swigregister = _xapian.MatchDecider_swigregister
3730MatchDecider_swigregister(MatchDecider)
3731
3732class Enquire(object):
3733    """
3734
3735
3736    This class provides an interface to the information retrieval system
3737    for the purpose of searching.
3738
3739    Databases are usually opened lazily, so exceptions may not be thrown
3740    where you would expect them to be. You should catch Xapian::Error
3741    exceptions when calling any method in Xapian::Enquire.
3742
3743    Parameters:
3744    -----------
3745
3746    Xapian::InvalidArgumentError:  will be thrown if an invalid argument
3747    is supplied, for example, an unknown database type.
3748    """
3749
3750    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
3751    __repr__ = _swig_repr
3752
3753    def __init__(self, database):
3754        """
3755
3756
3757        Create a Xapian::Enquire object.
3758
3759        Xapian::Enquire::Enquire(const Database &database, ErrorHandler
3760        *errorhandler_)
3761
3762        This specification cannot be changed once the Xapian::Enquire is
3763        opened: you must create a new Xapian::Enquire object to access a
3764        different database, or set of databases.
3765
3766        The database supplied must have been initialised (ie, must not be the
3767        result of calling the Database::Database() constructor). If you need
3768        to handle a situation where you have no databases gracefully, a
3769        database created with DB_BACKEND_INMEMORY can be passed here to
3770        provide a completely empty database.
3771
3772        Parameters:
3773        -----------
3774
3775        database:  Specification of the database or databases to use.
3776
3777        errorhandler_:  This parameter is deprecated (since Xapian 1.3.1), and
3778        as of 1.3.5 it's ignored completely.
3779
3780        Parameters:
3781        -----------
3782
3783        Xapian::InvalidArgumentError:  will be thrown if an empty Database
3784        object is supplied.
3785        """
3786        _xapian.Enquire_swiginit(self, _xapian.new_Enquire(database))
3787    __swig_destroy__ = _xapian.delete_Enquire
3788
3789    def set_query(self, query, qlen=0):
3790        """
3791
3792
3793        Set the query to run.
3794
3795        void Xapian::Enquire::set_query(const Xapian::Query &query,
3796        Xapian::termcount qlen=0)
3797
3798        Parameters:
3799        -----------
3800
3801        query:  the new query to run.
3802
3803        qlen:  the query length to use in weight calculations - by default the
3804        sum of the wqf of all terms is used.
3805        """
3806        return _xapian.Enquire_set_query(self, query, qlen)
3807
3808
3809    def get_query(self):
3810        """
3811
3812
3813        Get the current query.
3814
3815        const Xapian::Query& Xapian::Enquire::get_query() const
3816
3817        If called before set_query(), this will return a default initialised
3818        Query object.
3819        """
3820        return _xapian.Enquire_get_query(self)
3821
3822
3823    def add_matchspy(self, spy):
3824        """
3825
3826
3827        Add a matchspy.
3828
3829        void Xapian::Enquire::add_matchspy(MatchSpy *spy)
3830
3831        This matchspy will be called with some of the documents which match
3832        the query, during the match process. Exactly which of the matching
3833        documents are passed to it depends on exactly when certain
3834        optimisations occur during the match process, but it can be controlled
3835        to some extent by setting the checkatleast parameter to  get_mset().
3836
3837        In particular, if there are enough matching documents, at least the
3838        number specified by checkatleast will be passed to the matchspy. This
3839        means that you can force the matchspy to be shown all matching
3840        documents by setting checkatleast to the number of documents in the
3841        database.
3842
3843        Parameters:
3844        -----------
3845
3846        spy:  The MatchSpy subclass to add. The caller must ensure that this
3847        remains valid while the Enquire object remains active, or until
3848        clear_matchspies() is called.
3849        """
3850        return _xapian.Enquire_add_matchspy(self, spy)
3851
3852
3853    def clear_matchspies(self):
3854        """
3855
3856
3857        Remove all the matchspies.
3858
3859        void Xapian::Enquire::clear_matchspies()
3860        """
3861        return _xapian.Enquire_clear_matchspies(self)
3862
3863
3864    def set_weighting_scheme(self, weight_):
3865        """
3866
3867
3868        Set the weighting scheme to use for queries.
3869
3870        void Xapian::Enquire::set_weighting_scheme(const Weight &weight_)
3871
3872        Parameters:
3873        -----------
3874
3875        weight_:  the new weighting scheme. If no weighting scheme is
3876        specified, the default is BM25 with the default parameters.
3877        """
3878        return _xapian.Enquire_set_weighting_scheme(self, weight_)
3879
3880
3881    def set_expansion_scheme(self, eweightname_, expand_k_=1.0):
3882        """
3883
3884
3885        Set the weighting scheme to use for expansion.
3886
3887        void Xapian::Enquire::set_expansion_scheme(const std::string
3888        &eweightname_, double expand_k_=1.0) const
3889
3890        If you don't call this method, the default is as if you'd used:
3891
3892        get_expansion_scheme("trad");
3893
3894        Parameters:
3895        -----------
3896
3897        eweightname_:  A string in lowercase specifying the name of the scheme
3898        to be used. The following schemes are currently available: "bo1" :
3899        The Bo1 scheme for query expansion. "trad" : The TradWeight scheme
3900        for query expansion.
3901
3902        expand_k_:  The parameter required for TradWeight query expansion. A
3903        default value of 1.0 is used if none is specified.
3904        """
3905        return _xapian.Enquire_set_expansion_scheme(self, eweightname_, expand_k_)
3906
3907
3908    def set_collapse_key(self, collapse_key, collapse_max=1):
3909        """
3910
3911
3912        Set the collapse key to use for queries.
3913
3914        void Xapian::Enquire::set_collapse_key(Xapian::valueno collapse_key,
3915        Xapian::doccount collapse_max=1)
3916
3917        Parameters:
3918        -----------
3919
3920        collapse_key:  value number to collapse on - at most one MSet entry
3921        with each particular value will be returned (default is
3922        Xapian::BAD_VALUENO which means no collapsing).
3923
3924        collapse_max:  Max number of items with the same key to leave after
3925        collapsing (default 1).
3926
3927        The MSet returned by get_mset() will have only the "best" (at most)
3928        collapse_max entries with each particular value of collapse_key
3929        ("best" being highest ranked - i.e. highest weight or highest
3930        sorting key).
3931
3932        An example use might be to create a value for each document containing
3933        an MD5 hash of the document contents. Then duplicate documents from
3934        different sources can be eliminated at search time by collapsing with
3935        collapse_max = 1 (it's better to eliminate duplicates at index time,
3936        but this may not be always be possible - for example the search may be
3937        over more than one Xapian database).
3938
3939        Another use is to group matches in a particular category (e.g. you
3940        might collapse a mailing list search on the Subject: so that there's
3941        only one result per discussion thread). In this case you can use
3942        get_collapse_count() to give the user some idea how many other results
3943        there are. And if you index the Subject: as a boolean term as well as
3944        putting it in a value, you can offer a link to a non-collapsed search
3945        restricted to that thread using a boolean filter.
3946        """
3947        return _xapian.Enquire_set_collapse_key(self, collapse_key, collapse_max)
3948
3949    ASCENDING = _xapian.Enquire_ASCENDING
3950    DESCENDING = _xapian.Enquire_DESCENDING
3951    DONT_CARE = _xapian.Enquire_DONT_CARE
3952
3953    def set_docid_order(self, order):
3954        """
3955
3956
3957        Set sort order for document IDs.
3958
3959        void Xapian::Enquire::set_docid_order(docid_order order)
3960
3961        This order only has an effect on documents which would otherwise have
3962        equal rank. When ordering by relevance without a sort key, this means
3963        documents with equal weight. For a boolean match with no sort key,
3964        this means all documents. And if a sort key is used, this means
3965        documents with the same sort key (and also equal weight if ordering on
3966        relevance before or after the sort key).
3967
3968        Parameters:
3969        -----------
3970
3971        order:  This can be:  Xapian::Enquire::ASCENDING docids sort in
3972        ascending order (default)
3973
3974        Xapian::Enquire::DESCENDING docids sort in descending order
3975
3976        Xapian::Enquire::DONT_CARE docids sort in whatever order is most
3977        efficient for the backend
3978
3979        Note: If you add documents in strict date order, then a boolean search
3980        - i.e. set_weighting_scheme(Xapian::BoolWeight()) - with
3981        set_docid_order(Xapian::Enquire::DESCENDING) is an efficient way to
3982        perform "sort by date, newest first", and with
3983        set_docid_order(Xapian::Enquire::ASCENDING) a very efficient way to
3984        perform "sort by date, oldest first".
3985        """
3986        return _xapian.Enquire_set_docid_order(self, order)
3987
3988
3989    def set_cutoff(self, percent_cutoff, weight_cutoff=0):
3990        """
3991
3992
3993        Set the percentage and/or weight cutoffs.
3994
3995        void Xapian::Enquire::set_cutoff(int percent_cutoff, double
3996        weight_cutoff=0)
3997
3998        Parameters:
3999        -----------
4000
4001        percent_cutoff:  Minimum percentage score for returned documents. If a
4002        document has a lower percentage score than this, it will not appear in
4003        the MSet. If your intention is to return only matches which contain
4004        all the terms in the query, then it's more efficient to use
4005        Xapian::Query::OP_AND instead of Xapian::Query::OP_OR in the query
4006        than to use set_cutoff(100). (default 0 => no percentage cut-off).
4007
4008        weight_cutoff:  Minimum weight for a document to be returned. If a
4009        document has a lower score that this, it will not appear in the MSet.
4010        It is usually only possible to choose an appropriate weight for cutoff
4011        based on the results of a previous run of the same query; this is thus
4012        mainly useful for alerting operations. The other potential use is with
4013        a user specified weighting scheme. (default 0 => no weight cut-off).
4014
4015        """
4016        return _xapian.Enquire_set_cutoff(self, percent_cutoff, weight_cutoff)
4017
4018
4019    def set_sort_by_relevance(self):
4020        """
4021
4022
4023        Set the sorting to be by relevance only.
4024
4025        void Xapian::Enquire::set_sort_by_relevance()
4026
4027        This is the default.
4028        """
4029        return _xapian.Enquire_set_sort_by_relevance(self)
4030
4031
4032    def set_sort_by_value(self, sort_key, reverse):
4033        """
4034
4035
4036        Set the sorting to be by value only.
4037
4038        void Xapian::Enquire::set_sort_by_value(Xapian::valueno sort_key, bool
4039        reverse)
4040
4041        Note that sorting by values uses a string comparison, so to use this
4042        to sort by a numeric value you'll need to store the numeric values in
4043        a manner which sorts appropriately. For example, you could use
4044        Xapian::sortable_serialise() (which works for floating point numbers
4045        as well as integers), or store numbers padded with leading zeros or
4046        spaces, or with the number of digits prepended.
4047
4048        Parameters:
4049        -----------
4050
4051        sort_key:  value number to sort on.
4052
4053        reverse:  If true, reverses the sort order.
4054        """
4055        return _xapian.Enquire_set_sort_by_value(self, sort_key, reverse)
4056
4057
4058    def set_sort_by_key(self, sorter, reverse):
4059        """
4060
4061
4062        Set the sorting to be by key generated from values only.
4063
4064        void Xapian::Enquire::set_sort_by_key(Xapian::KeyMaker *sorter, bool
4065        reverse)
4066
4067        Parameters:
4068        -----------
4069
4070        sorter:  The functor to use for generating keys.
4071
4072        reverse:  If true, reverses the sort order.
4073        """
4074        return _xapian.Enquire_set_sort_by_key(self, sorter, reverse)
4075
4076
4077    def set_sort_by_value_then_relevance(self, sort_key, reverse):
4078        """
4079
4080
4081        Set the sorting to be by value, then by relevance for documents with
4082        the same value.
4083
4084        void Xapian::Enquire::set_sort_by_value_then_relevance(Xapian::valueno
4085        sort_key, bool reverse)
4086
4087        Note that sorting by values uses a string comparison, so to use this
4088        to sort by a numeric value you'll need to store the numeric values in
4089        a manner which sorts appropriately. For example, you could use
4090        Xapian::sortable_serialise() (which works for floating point numbers
4091        as well as integers), or store numbers padded with leading zeros or
4092        spaces, or with the number of digits prepended.
4093
4094        Parameters:
4095        -----------
4096
4097        sort_key:  value number to sort on.
4098
4099        reverse:  If true, reverses the sort order.
4100        """
4101        return _xapian.Enquire_set_sort_by_value_then_relevance(self, sort_key, reverse)
4102
4103
4104    def set_sort_by_key_then_relevance(self, sorter, reverse):
4105        """
4106
4107
4108        Set the sorting to be by keys generated from values, then by relevance
4109        for documents with identical keys.
4110
4111        void Xapian::Enquire::set_sort_by_key_then_relevance(Xapian::KeyMaker
4112        *sorter, bool reverse)
4113
4114        Parameters:
4115        -----------
4116
4117        sorter:  The functor to use for generating keys.
4118
4119        reverse:  If true, reverses the sort order.
4120        """
4121        return _xapian.Enquire_set_sort_by_key_then_relevance(self, sorter, reverse)
4122
4123
4124    def set_sort_by_relevance_then_value(self, sort_key, reverse):
4125        """
4126
4127
4128        Set the sorting to be by relevance then value.
4129
4130        void Xapian::Enquire::set_sort_by_relevance_then_value(Xapian::valueno
4131        sort_key, bool reverse)
4132
4133        Note that sorting by values uses a string comparison, so to use this
4134        to sort by a numeric value you'll need to store the numeric values in
4135        a manner which sorts appropriately. For example, you could use
4136        Xapian::sortable_serialise() (which works for floating point numbers
4137        as well as integers), or store numbers padded with leading zeros or
4138        spaces, or with the number of digits prepended.
4139
4140        Note that with the default BM25 weighting scheme parameters, non-
4141        identical documents will rarely have the same weight, so this setting
4142        will give very similar results to set_sort_by_relevance(). It becomes
4143        more useful with particular BM25 parameter settings (e.g.
4144        BM25Weight(1,0,1,0,0)) or custom weighting schemes.
4145
4146        Parameters:
4147        -----------
4148
4149        sort_key:  value number to sort on.
4150
4151        reverse:  If true, reverses the sort order of sort_key. Beware that in
4152        1.2.16 and earlier, the sense of this parameter was incorrectly
4153        inverted and inconsistent with the other set_sort_by_... methods. This
4154        was fixed in 1.2.17, so make that version a minimum requirement if
4155        this detail matters to your application.
4156        """
4157        return _xapian.Enquire_set_sort_by_relevance_then_value(self, sort_key, reverse)
4158
4159
4160    def set_sort_by_relevance_then_key(self, sorter, reverse):
4161        """
4162
4163
4164        Set the sorting to be by relevance, then by keys generated from
4165        values.
4166
4167        void Xapian::Enquire::set_sort_by_relevance_then_key(Xapian::KeyMaker
4168        *sorter, bool reverse)
4169
4170        Note that with the default BM25 weighting scheme parameters, non-
4171        identical documents will rarely have the same weight, so this setting
4172        will give very similar results to set_sort_by_relevance(). It becomes
4173        more useful with particular BM25 parameter settings (e.g.
4174        BM25Weight(1,0,1,0,0)) or custom weighting schemes.
4175
4176        Parameters:
4177        -----------
4178
4179        sorter:  The functor to use for generating keys.
4180
4181        reverse:  If true, reverses the sort order of the generated keys.
4182        Beware that in 1.2.16 and earlier, the sense of this parameter was
4183        incorrectly inverted and inconsistent with the other set_sort_by_...
4184        methods. This was fixed in 1.2.17, so make that version a minimum
4185        requirement if this detail matters to your application.
4186        """
4187        return _xapian.Enquire_set_sort_by_relevance_then_key(self, sorter, reverse)
4188
4189
4190    def set_time_limit(self, time_limit):
4191        """
4192
4193
4194        Set a time limit for the match.
4195
4196        void Xapian::Enquire::set_time_limit(double time_limit)
4197
4198        Matches with check_at_least set high can take a long time in some
4199        cases. You can set a time limit on this, after which check_at_least
4200        will be turned off.
4201
4202        Parameters:
4203        -----------
4204
4205        time_limit:  time in seconds after which to disable check_at_least
4206        (default: 0.0 which means no time limit)
4207
4208        Limitations:
4209
4210        This feature is currently supported on platforms which support POSIX
4211        interval timers. Interaction with the remote backend when using
4212        multiple databases may have bugs. There's not currently a way to force
4213        the match to end after a certain time.
4214        """
4215        return _xapian.Enquire_set_time_limit(self, time_limit)
4216
4217
4218    def get_mset(self, *args):
4219        """
4220
4221
4222        Get (a portion of) the match set for the current query.
4223
4224        MSet Xapian::Enquire::get_mset(Xapian::doccount first,
4225        Xapian::doccount maxitems, const RSet *omrset, const MatchDecider
4226        *mdecider=0) const
4227
4228        Parameters:
4229        -----------
4230
4231        first:  the first item in the result set to return. A value of zero
4232        corresponds to the first item returned being that with the highest
4233        score. A value of 10 corresponds to the first 10 items being ignored,
4234        and the returned items starting at the eleventh.
4235
4236        maxitems:  the maximum number of items to return. If you want all
4237        matches, then you can pass the result of calling get_doccount() on the
4238        Database object (though if you are doing this so you can filter
4239        results, you are likely to get much better performance by using
4240        Xapian's match-time filtering features instead). You can pass 0 for
4241        maxitems which will give you an empty MSet with valid statistics (such
4242        as get_matches_estimated()) calculated without looking at any
4243        postings, which is very quick, but means the estimates may be more
4244        approximate and the bounds may be much looser.
4245
4246        omrset:  the relevance set to use when performing the query.
4247
4248        mdecider:  a decision functor to use to decide whether a given
4249        document should be put in the MSet.
4250
4251        A Xapian::MSet object containing the results of the query.
4252
4253        Parameters:
4254        -----------
4255
4256        Xapian::InvalidArgumentError:  See class documentation.
4257        """
4258        return _xapian.Enquire_get_mset(self, *args)
4259
4260    INCLUDE_QUERY_TERMS = _xapian.Enquire_INCLUDE_QUERY_TERMS
4261    USE_EXACT_TERMFREQ = _xapian.Enquire_USE_EXACT_TERMFREQ
4262
4263    def get_eset(self, *args):
4264        """
4265
4266
4267        Get the expand set for the given rset.
4268
4269        ESet Xapian::Enquire::get_eset(Xapian::termcount maxitems, const RSet
4270        &rset, int flags, double k, const Xapian::ExpandDecider
4271        *edecider=NULL, double min_wt=0.0) const
4272
4273        Parameters:
4274        -----------
4275
4276        maxitems:  the maximum number of items to return.
4277
4278        rset:  the relevance set to use when performing the expand operation.
4279
4280        flags:  zero or more of these values |-ed together:
4281        Xapian::Enquire::INCLUDE_QUERY_TERMS query terms may be returned from
4282        expand
4283
4284        Xapian::Enquire::USE_EXACT_TERMFREQ for multi dbs, calculate the exact
4285        termfreq; otherwise an approximation is used which can greatly improve
4286        efficiency, but still returns good results.
4287
4288        k:  the parameter k in the query expansion algorithm (default is 1.0)
4289
4290        edecider:  a decision functor to use to decide whether a given term
4291        should be put in the ESet
4292
4293        min_wt:  the minimum weight for included terms
4294
4295        An ESet object containing the results of the expand.
4296
4297        Parameters:
4298        -----------
4299
4300        Xapian::InvalidArgumentError:  See class documentation.
4301        """
4302        return _xapian.Enquire_get_eset(self, *args)
4303
4304
4305    def _get_matching_terms_begin(self, *args):
4306        """
4307
4308
4309        Get terms which match a given document, by match set item.
4310
4311        TermIterator Xapian::Enquire::get_matching_terms_begin(const
4312        MSetIterator &it) const
4313
4314        This method returns the terms in the current query which match the
4315        given document.
4316
4317        If the underlying database has suitable support, using this call
4318        (rather than passing a Xapian::docid) will enable the system to ensure
4319        that the correct data is returned, and that the document has not been
4320        deleted or changed since the query was performed.
4321
4322        Parameters:
4323        -----------
4324
4325        it:  The iterator for which to retrieve the matching terms.
4326
4327        An iterator returning the terms which match the document. The terms
4328        will be returned (as far as this makes any sense) in the same order as
4329        the terms in the query. Terms will not occur more than once, even if
4330        they do in the query.
4331
4332        Parameters:
4333        -----------
4334
4335        Xapian::InvalidArgumentError:  See class documentation.
4336
4337        Xapian::DocNotFoundError:  The document specified could not be found
4338        in the database.
4339        """
4340        return _xapian.Enquire__get_matching_terms_begin(self, *args)
4341
4342
4343    def _get_matching_terms_end(self, *args):
4344        """
4345
4346
4347        End iterator corresponding to get_matching_terms_begin()
4348
4349        TermIterator Xapian::Enquire::get_matching_terms_end(const
4350        MSetIterator &) const
4351        """
4352        return _xapian.Enquire__get_matching_terms_end(self, *args)
4353
4354
4355    def __str__(self):
4356        """
4357
4358
4359        Return a string describing this object.
4360
4361        std::string Xapian::Enquire::get_description() const
4362        """
4363        return _xapian.Enquire___str__(self)
4364
4365Enquire.set_query = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire_set_query)
4366Enquire.get_query = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire_get_query)
4367Enquire.add_matchspy = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire_add_matchspy)
4368Enquire.clear_matchspies = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire_clear_matchspies)
4369Enquire.set_weighting_scheme = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire_set_weighting_scheme)
4370Enquire.set_expansion_scheme = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire_set_expansion_scheme)
4371Enquire.set_collapse_key = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire_set_collapse_key)
4372Enquire.set_docid_order = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire_set_docid_order)
4373Enquire.set_cutoff = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire_set_cutoff)
4374Enquire.set_sort_by_relevance = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire_set_sort_by_relevance)
4375Enquire.set_sort_by_value = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire_set_sort_by_value)
4376Enquire.set_sort_by_key = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire_set_sort_by_key)
4377Enquire.set_sort_by_value_then_relevance = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire_set_sort_by_value_then_relevance)
4378Enquire.set_sort_by_key_then_relevance = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire_set_sort_by_key_then_relevance)
4379Enquire.set_sort_by_relevance_then_value = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire_set_sort_by_relevance_then_value)
4380Enquire.set_sort_by_relevance_then_key = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire_set_sort_by_relevance_then_key)
4381Enquire.set_time_limit = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire_set_time_limit)
4382Enquire.get_mset = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire_get_mset)
4383Enquire.get_eset = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire_get_eset)
4384Enquire._get_matching_terms_begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire__get_matching_terms_begin)
4385Enquire._get_matching_terms_end = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire__get_matching_terms_end)
4386Enquire.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.Enquire___str__)
4387Enquire_swigregister = _xapian.Enquire_swigregister
4388Enquire_swigregister(Enquire)
4389
4390class ExpandDecider(object):
4391    """
4392
4393
4394    Virtual base class for expand decider functor.
4395    """
4396
4397    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
4398    __repr__ = _swig_repr
4399
4400    def __init__(self):
4401        """
4402
4403
4404        Default constructor.
4405
4406        Xapian::ExpandDecider::ExpandDecider()
4407        """
4408        if self.__class__ == ExpandDecider:
4409            _self = None
4410        else:
4411            _self = self
4412        _xapian.ExpandDecider_swiginit(self, _xapian.new_ExpandDecider(_self, ))
4413    __swig_destroy__ = _xapian.delete_ExpandDecider
4414
4415    def release(self):
4416        """
4417
4418
4419        Start reference counting this object.
4420
4421        const ExpandDecider* Xapian::ExpandDecider::release() const
4422
4423        You can hand ownership of a dynamically allocated ExpandDecider object
4424        to Xapian by calling release() and then passing the object to a Xapian
4425        method. Xapian will arrange to delete the object once it is no longer
4426        required.
4427        """
4428        return _xapian.ExpandDecider_release(self)
4429
4430    def __disown__(self):
4431        self.this.disown()
4432        _xapian.disown_ExpandDecider(self)
4433        return weakref_proxy(self)
4434ExpandDecider.__call__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.ExpandDecider___call__)
4435ExpandDecider.release = _xapian.SWIG_PyInstanceMethod_New(_xapian.ExpandDecider_release)
4436ExpandDecider_swigregister = _xapian.ExpandDecider_swigregister
4437ExpandDecider_swigregister(ExpandDecider)
4438
4439class ExpandDeciderAnd(ExpandDecider):
4440    """
4441
4442
4443    ExpandDecider subclass which rejects terms using two ExpandDeciders.
4444
4445    Terms are only accepted if they are accepted by both of the specified
4446    ExpandDecider objects.
4447    """
4448
4449    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
4450    __repr__ = _swig_repr
4451
4452    def __init__(self, first_, second_):
4453        """
4454
4455
4456        Compatibility method.
4457
4458        Xapian::ExpandDeciderAnd::ExpandDeciderAnd(const ExpandDecider
4459        *first_, const ExpandDecider *second_)
4460
4461        Parameters:
4462        -----------
4463
4464        first_:  First ExpandDecider object to test with.
4465
4466        second_:   ExpandDecider object to test with if first_ accepts.
4467        """
4468        _xapian.ExpandDeciderAnd_swiginit(self, _xapian.new_ExpandDeciderAnd(first_, second_))
4469    __swig_destroy__ = _xapian.delete_ExpandDeciderAnd
4470ExpandDeciderAnd_swigregister = _xapian.ExpandDeciderAnd_swigregister
4471ExpandDeciderAnd_swigregister(ExpandDeciderAnd)
4472
4473class ExpandDeciderFilterPrefix(ExpandDecider):
4474    """
4475
4476
4477    ExpandDecider subclass which restrict terms to a particular prefix.
4478
4479    ExpandDeciderFilterPrefix provides an easy way to choose terms with a
4480    particular prefix when generating an ESet.
4481    """
4482
4483    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
4484    __repr__ = _swig_repr
4485
4486    def __init__(self, prefix_):
4487        """
4488
4489
4490        The parameter specify the prefix of terms to be retained.
4491
4492        Xapian::ExpandDeciderFilterPrefix::ExpandDeciderFilterPrefix(const
4493        std::string &prefix_)
4494
4495        Parameters:
4496        -----------
4497
4498        prefix_:  restrict terms to the particular prefix_
4499        """
4500        _xapian.ExpandDeciderFilterPrefix_swiginit(self, _xapian.new_ExpandDeciderFilterPrefix(prefix_))
4501    __swig_destroy__ = _xapian.delete_ExpandDeciderFilterPrefix
4502ExpandDeciderFilterPrefix_swigregister = _xapian.ExpandDeciderFilterPrefix_swigregister
4503ExpandDeciderFilterPrefix_swigregister(ExpandDeciderFilterPrefix)
4504
4505class KeyMaker(object):
4506    """
4507
4508
4509    Virtual base class for key making functors.
4510    """
4511
4512    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
4513    __repr__ = _swig_repr
4514
4515    def __init__(self):
4516        """
4517
4518
4519        Default constructor.
4520
4521        Xapian::KeyMaker::KeyMaker()
4522        """
4523        if self.__class__ == KeyMaker:
4524            _self = None
4525        else:
4526            _self = self
4527        _xapian.KeyMaker_swiginit(self, _xapian.new_KeyMaker(_self, ))
4528    __swig_destroy__ = _xapian.delete_KeyMaker
4529
4530    def release(self):
4531        """
4532
4533
4534        Start reference counting this object.
4535
4536        const KeyMaker* Xapian::KeyMaker::release() const
4537
4538        You can hand ownership of a dynamically allocated KeyMaker object to
4539        Xapian by calling release() and then passing the object to a Xapian
4540        method. Xapian will arrange to delete the object once it is no longer
4541        required.
4542        """
4543        return _xapian.KeyMaker_release(self)
4544
4545    def __disown__(self):
4546        self.this.disown()
4547        _xapian.disown_KeyMaker(self)
4548        return weakref_proxy(self)
4549KeyMaker.__call__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.KeyMaker___call__)
4550KeyMaker.release = _xapian.SWIG_PyInstanceMethod_New(_xapian.KeyMaker_release)
4551KeyMaker_swigregister = _xapian.KeyMaker_swigregister
4552KeyMaker_swigregister(KeyMaker)
4553
4554class MultiValueKeyMaker(KeyMaker):
4555    """
4556
4557
4558    KeyMaker subclass which combines several values.
4559
4560    When the result is used for sorting, results are ordered by the first
4561    value. In the event of a tie, the second is used. If this is the same
4562    for both, the third is used, and so on. If reverse is true for a
4563    value, then the sort order for that value is reversed.
4564
4565    When used for collapsing, the documents will only be considered equal
4566    if all the values specified match. If none of the specified values are
4567    set then the generated key will be empty, so such documents won't be
4568    collapsed (which is consistent with the behaviour in the "collapse on
4569    a value" case). If you'd prefer that documents with none of the keys
4570    set are collapsed together, then you can set reverse for at least one
4571    of the values. Other than this, it isn't useful to set reverse for
4572    collapsing.
4573    """
4574
4575    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
4576    __repr__ = _swig_repr
4577
4578    def __init__(self):
4579        """
4580
4581
4582        Construct a MultiValueKeyMaker from a pair of iterators.
4583
4584        Xapian::MultiValueKeyMaker::MultiValueKeyMaker(Iterator begin,
4585        Iterator end)
4586
4587        The iterators must be a begin/end pair returning Xapian::valueno (or a
4588        compatible type) when dereferenced.
4589        """
4590        _xapian.MultiValueKeyMaker_swiginit(self, _xapian.new_MultiValueKeyMaker())
4591
4592    def add_value(self, *args):
4593        """
4594
4595
4596        Add a value slot to the list to build a key from.
4597
4598        void Xapian::MultiValueKeyMaker::add_value(Xapian::valueno slot, bool
4599        reverse=false, const std::string &defvalue=std::string())
4600
4601        Parameters:
4602        -----------
4603
4604        slot:  The value slot to add
4605
4606        reverse:  Adjust values from this slot to reverse their sort order
4607        (default: false)
4608
4609        defvalue:  Value to use for documents which don't have a value set in
4610        this slot (default: empty). This can be used to make such documents
4611        sort after all others by passing get_value_upper_bound(slot) + "x"
4612        this is guaranteed to be greater than any value in this slot.
4613        """
4614        return _xapian.MultiValueKeyMaker_add_value(self, *args)
4615
4616    __swig_destroy__ = _xapian.delete_MultiValueKeyMaker
4617MultiValueKeyMaker.add_value = _xapian.SWIG_PyInstanceMethod_New(_xapian.MultiValueKeyMaker_add_value)
4618MultiValueKeyMaker_swigregister = _xapian.MultiValueKeyMaker_swigregister
4619MultiValueKeyMaker_swigregister(MultiValueKeyMaker)
4620
4621RP_SUFFIX = _xapian.RP_SUFFIX
4622RP_REPEATED = _xapian.RP_REPEATED
4623RP_DATE_PREFER_MDY = _xapian.RP_DATE_PREFER_MDY
4624class Stopper(object):
4625    """
4626
4627
4628    Base class for stop-word decision functor.
4629    """
4630
4631    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
4632    __repr__ = _swig_repr
4633
4634    def __init__(self):
4635        """
4636
4637
4638        Default constructor.
4639
4640        Xapian::Stopper::Stopper()
4641        """
4642        if self.__class__ == Stopper:
4643            _self = None
4644        else:
4645            _self = self
4646        _xapian.Stopper_swiginit(self, _xapian.new_Stopper(_self, ))
4647    __swig_destroy__ = _xapian.delete_Stopper
4648
4649    def __str__(self):
4650        """
4651
4652
4653        Return a string describing this object.
4654
4655        virtual std::string Xapian::Stopper::get_description() const
4656        """
4657        return _xapian.Stopper___str__(self)
4658
4659
4660    def release(self):
4661        """
4662
4663
4664        Start reference counting this object.
4665
4666        const Stopper* Xapian::Stopper::release() const
4667
4668        You can hand ownership of a dynamically allocated Stopper object to
4669        Xapian by calling release() and then passing the object to a Xapian
4670        method. Xapian will arrange to delete the object once it is no longer
4671        required.
4672        """
4673        return _xapian.Stopper_release(self)
4674
4675    def __disown__(self):
4676        self.this.disown()
4677        _xapian.disown_Stopper(self)
4678        return weakref_proxy(self)
4679Stopper.__call__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.Stopper___call__)
4680Stopper.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.Stopper___str__)
4681Stopper.release = _xapian.SWIG_PyInstanceMethod_New(_xapian.Stopper_release)
4682Stopper_swigregister = _xapian.Stopper_swigregister
4683Stopper_swigregister(Stopper)
4684
4685class SimpleStopper(Stopper):
4686    """
4687
4688
4689    Simple implementation of Stopper class - this will suit most users.
4690    """
4691
4692    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
4693    __repr__ = _swig_repr
4694
4695    def add(self, word):
4696        """
4697
4698
4699        Add a single stop word.
4700
4701        void Xapian::SimpleStopper::add(const std::string &word)
4702        """
4703        return _xapian.SimpleStopper_add(self, word)
4704
4705
4706    def __init__(self, *args):
4707        """
4708
4709
4710        Initialise from a pair of iterators.
4711
4712        Xapian::SimpleStopper::SimpleStopper(Iterator begin, Iterator end)
4713
4714        Xapian includes stop list files for many languages. You can initialise
4715        from a file like that:
4716        """
4717        _xapian.SimpleStopper_swiginit(self, _xapian.new_SimpleStopper(*args))
4718    __swig_destroy__ = _xapian.delete_SimpleStopper
4719SimpleStopper.add = _xapian.SWIG_PyInstanceMethod_New(_xapian.SimpleStopper_add)
4720SimpleStopper_swigregister = _xapian.SimpleStopper_swigregister
4721SimpleStopper_swigregister(SimpleStopper)
4722
4723class RangeProcessor(object):
4724    """
4725
4726
4727    Base class for range processors.
4728    """
4729
4730    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
4731    __repr__ = _swig_repr
4732
4733    def __init__(self, *args):
4734        """
4735
4736
4737        Constructor.
4738
4739        Xapian::RangeProcessor::RangeProcessor(Xapian::valueno slot_, const
4740        std::string &str_=std::string(), unsigned flags_=0)
4741
4742        Parameters:
4743        -----------
4744
4745        slot_:  Which value slot to generate ranges over.
4746
4747        str_:  A string to look for to recognise values as belonging to this
4748        range (as a prefix by default, or as a suffix if flags
4749        Xapian::RP_SUFFIX is specified).
4750
4751        flags_:  Zero or more of the following flags, combined with bitwise-or
4752        (| in C++): Xapian::RP_SUFFIX - require str_ as a suffix instead of a
4753        prefix.
4754
4755        Xapian::RP_REPEATED - optionally allow str_ on both ends of the range
4756        - e.g. $1..$10 or 5m..50m. By default a prefix is only checked for on
4757        the start (e.g. date:1/1/1980..31/12/1989), and a suffix only on the
4758        end (e.g. 2..12kg).
4759        """
4760        if self.__class__ == RangeProcessor:
4761            _self = None
4762        else:
4763            _self = self
4764        _xapian.RangeProcessor_swiginit(self, _xapian.new_RangeProcessor(_self, *args))
4765    __swig_destroy__ = _xapian.delete_RangeProcessor
4766
4767    def check_range(self, b, e):
4768        """
4769
4770
4771        Check prefix/suffix on range.
4772
4773        Xapian::Query Xapian::RangeProcessor::check_range(const std::string
4774        &b, const std::string &e)
4775
4776        If they match, remove the prefix/suffix and then call operator()() to
4777        try to handle the range.
4778        """
4779        return _xapian.RangeProcessor_check_range(self, b, e)
4780
4781
4782    def release(self):
4783        """
4784
4785
4786        Start reference counting this object.
4787
4788        const RangeProcessor* Xapian::RangeProcessor::release() const
4789
4790        You can hand ownership of a dynamically allocated RangeProcessor
4791        object to Xapian by calling release() and then passing the object to a
4792        Xapian method. Xapian will arrange to delete the object once it is no
4793        longer required.
4794        """
4795        return _xapian.RangeProcessor_release(self)
4796
4797    def __disown__(self):
4798        self.this.disown()
4799        _xapian.disown_RangeProcessor(self)
4800        return weakref_proxy(self)
4801RangeProcessor.check_range = _xapian.SWIG_PyInstanceMethod_New(_xapian.RangeProcessor_check_range)
4802RangeProcessor.__call__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.RangeProcessor___call__)
4803RangeProcessor.release = _xapian.SWIG_PyInstanceMethod_New(_xapian.RangeProcessor_release)
4804RangeProcessor_swigregister = _xapian.RangeProcessor_swigregister
4805RangeProcessor_swigregister(RangeProcessor)
4806
4807class DateRangeProcessor(RangeProcessor):
4808    """
4809
4810
4811    Handle a date range.
4812
4813    Begin and end must be dates in a recognised format.
4814    """
4815
4816    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
4817    __repr__ = _swig_repr
4818
4819    def __init__(self, *args):
4820        """
4821
4822
4823        Constructor.
4824
4825        Xapian::DateRangeProcessor::DateRangeProcessor(Xapian::valueno slot_,
4826        const std::string &str_, unsigned flags_=0, int epoch_year_=1970)
4827
4828        Parameters:
4829        -----------
4830
4831        slot_:  The value slot number to query.
4832
4833        str_:  A string to look for to recognise values as belonging to this
4834        date range.
4835
4836        flags_:  Zero or more of the following flags, combined with bitwise-
4837        or: Xapian::RP_SUFFIX - require str_ as a suffix instead of a prefix.
4838
4839        Xapian::RP_REPEATED - optionally allow str_ on both ends of the range
4840        - e.g. $1..$10 or 5m..50m. By default a prefix is only checked for on
4841        the start (e.g. date:1/1/1980..31/12/1989), and a suffix only on the
4842        end (e.g. 2..12kg).
4843
4844        Xapian::RP_DATE_PREFER_MDY - interpret ambiguous dates as
4845        month/day/year rather than day/month/year.
4846
4847        epoch_year_:  Year to use as the epoch for dates with 2 digit years
4848        (default: 1970, so 1/1/69 is 2069 while 1/1/70 is 1970).
4849
4850        The string supplied in str_ is used by operator() to decide whether
4851        the pair of strings supplied to it constitute a valid range. If
4852        prefix_ is true, the first value in a range must begin with str_ (and
4853        the second value may optionally begin with str_); if prefix_ is false,
4854        the second value in a range must end with str_ (and the first value
4855        may optionally end with str_).
4856
4857        If str_ is empty, the Xapian::RP_SUFFIX and Xapian::RP_REPEATED are
4858        irrelevant, and no special strings are required at the start or end of
4859        the strings defining the range.
4860
4861        The remainder of both strings defining the endpoints must be valid
4862        dates.
4863
4864        For example, if str_ is "created:", Xapian::RP_SUFFIX is not
4865        specified, and the range processor has been added to the queryparser,
4866        the queryparser will accept "created:1/1/2000..31/12/2001".
4867        """
4868        _xapian.DateRangeProcessor_swiginit(self, _xapian.new_DateRangeProcessor(*args))
4869    __swig_destroy__ = _xapian.delete_DateRangeProcessor
4870DateRangeProcessor_swigregister = _xapian.DateRangeProcessor_swigregister
4871DateRangeProcessor_swigregister(DateRangeProcessor)
4872
4873class NumberRangeProcessor(RangeProcessor):
4874    """
4875
4876
4877    Handle a number range.
4878
4879    This class must be used on values which have been encoded using
4880    Xapian::sortable_serialise() which turns numbers into strings which
4881    will sort in the same order as the numbers (the same values can be
4882    used to implement a numeric sort).
4883    """
4884
4885    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
4886    __repr__ = _swig_repr
4887
4888    def __init__(self, *args):
4889        """
4890
4891
4892        Constructor.
4893
4894        Xapian::NumberRangeProcessor::NumberRangeProcessor(Xapian::valueno
4895        slot_, const std::string &str_=std::string(), unsigned flags_=0)
4896
4897        Parameters:
4898        -----------
4899
4900        slot_:  The value slot number to query.
4901
4902        str_:  A string to look for to recognise values as belonging to this
4903        numeric range.
4904
4905        flags_:  Zero or more of the following flags, combined with bitwise-
4906        or: Xapian::RP_SUFFIX - require str_ as a suffix instead of a prefix.
4907
4908        Xapian::RP_REPEATED - optionally allow str_ on both ends of the range
4909        - e.g. $1..$10 or 5m..50m. By default a prefix is only checked for on
4910        the start (e.g. date:1/1/1980..31/12/1989), and a suffix only on the
4911        end (e.g. 2..12kg).
4912
4913        The string supplied in str_ is used by operator() to decide whether
4914        the pair of strings supplied to it constitute a valid range. If
4915        prefix_ is true, the first value in a range must begin with str_ (and
4916        the second value may optionally begin with str_); if prefix_ is false,
4917        the second value in a range must end with str_ (and the first value
4918        may optionally end with str_).
4919
4920        If str_ is empty, the setting of prefix_ is irrelevant, and no special
4921        strings are required at the start or end of the strings defining the
4922        range.
4923
4924        The remainder of both strings defining the endpoints must be valid
4925        floating point numbers. (FIXME: define format recognised).
4926
4927        For example, if str_ is "$" and prefix_ is true, and the range
4928        processor has been added to the queryparser, the queryparser will
4929        accept "$10..50" or "$10..$50", but not "10..50" or "10..$50"
4930        as valid ranges. If str_ is "kg" and prefix_ is false, the
4931        queryparser will accept "10..50kg" or "10kg..50kg", but not
4932        "10..50" or "10kg..50" as valid ranges.
4933        """
4934        _xapian.NumberRangeProcessor_swiginit(self, _xapian.new_NumberRangeProcessor(*args))
4935    __swig_destroy__ = _xapian.delete_NumberRangeProcessor
4936NumberRangeProcessor_swigregister = _xapian.NumberRangeProcessor_swigregister
4937NumberRangeProcessor_swigregister(NumberRangeProcessor)
4938
4939class ValueRangeProcessor(object):
4940    """
4941
4942
4943    Base class for value range processors.
4944    """
4945
4946    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
4947    __repr__ = _swig_repr
4948
4949    def __init__(self):
4950        """
4951
4952
4953        Default constructor.
4954
4955        Xapian::ValueRangeProcessor::ValueRangeProcessor()
4956        """
4957        if self.__class__ == ValueRangeProcessor:
4958            _self = None
4959        else:
4960            _self = self
4961        _xapian.ValueRangeProcessor_swiginit(self, _xapian.new_ValueRangeProcessor(_self, ))
4962    __swig_destroy__ = _xapian.delete_ValueRangeProcessor
4963
4964    def release(self):
4965        """
4966
4967
4968        Start reference counting this object.
4969
4970        const ValueRangeProcessor* Xapian::ValueRangeProcessor::release()
4971        const
4972
4973        You can hand ownership of a dynamically allocated ValueRangeProcessor
4974        object to Xapian by calling release() and then passing the object to a
4975        Xapian method. Xapian will arrange to delete the object once it is no
4976        longer required.
4977        """
4978        return _xapian.ValueRangeProcessor_release(self)
4979
4980    def __disown__(self):
4981        self.this.disown()
4982        _xapian.disown_ValueRangeProcessor(self)
4983        return weakref_proxy(self)
4984ValueRangeProcessor.__call__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValueRangeProcessor___call__)
4985ValueRangeProcessor.release = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValueRangeProcessor_release)
4986ValueRangeProcessor_swigregister = _xapian.ValueRangeProcessor_swigregister
4987ValueRangeProcessor_swigregister(ValueRangeProcessor)
4988
4989class StringValueRangeProcessor(ValueRangeProcessor):
4990    """
4991
4992
4993    Handle a string range.
4994
4995    The end points can be any strings.
4996
4997    Deprecated Use Xapian::RangeProcessor instead (added in 1.3.6).
4998    """
4999
5000    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5001    __repr__ = _swig_repr
5002
5003    def __init__(self, *args):
5004        """
5005
5006
5007        Constructor.
5008
5009        Xapian::StringValueRangeProcessor::StringValueRangeProcessor(Xapian::valueno
5010        slot_, const std::string &str_, bool prefix_=true)
5011
5012        Parameters:
5013        -----------
5014
5015        slot_:  The value number to return from operator().
5016
5017        str_:  A string to look for to recognise values as belonging to this
5018        range.
5019
5020        prefix_:  Flag specifying whether to check for str_ as a prefix or a
5021        suffix.
5022        """
5023        _xapian.StringValueRangeProcessor_swiginit(self, _xapian.new_StringValueRangeProcessor(*args))
5024    __swig_destroy__ = _xapian.delete_StringValueRangeProcessor
5025StringValueRangeProcessor_swigregister = _xapian.StringValueRangeProcessor_swigregister
5026StringValueRangeProcessor_swigregister(StringValueRangeProcessor)
5027
5028class DateValueRangeProcessor(StringValueRangeProcessor):
5029    """
5030
5031
5032    Handle a date range.
5033
5034    Begin and end must be dates in a recognised format.
5035
5036    Deprecated Use Xapian::DateRangeProcessor instead (added in 1.3.6).
5037    """
5038
5039    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5040    __repr__ = _swig_repr
5041
5042    def __init__(self, *args):
5043        """
5044
5045
5046        Constructor.
5047
5048        Xapian::DateValueRangeProcessor::DateValueRangeProcessor(Xapian::valueno
5049        slot_, const char *str_, bool prefix_=true, bool prefer_mdy_=false,
5050        int epoch_year_=1970)
5051
5052        This is like the previous version, but with const char * instead of
5053        std::string - we need this overload as otherwise
5054        DateValueRangeProcessor(1, "date:") quietly interprets the second
5055        argument as a boolean in preference to std::string. If you want to be
5056        compatible with 1.2.12 and earlier, then explicitly convert to
5057        std::string, i.e.: DateValueRangeProcessor(1, std::string("date:"))
5058
5059        Parameters:
5060        -----------
5061
5062        slot_:  The value number to return from operator().
5063
5064        str_:  A string to look for to recognise values as belonging to this
5065        date range.
5066
5067        prefix_:  Whether to look for the string at the start or end of the
5068        values. If true, the string is a prefix; if false, the string is a
5069        suffix (default: true).
5070
5071        prefer_mdy_:  Should ambiguous dates be interpreted as month/day/year
5072        rather than day/month/year? (default: false)
5073
5074        epoch_year_:  Year to use as the epoch for dates with 2 digit years
5075        (default: 1970, so 1/1/69 is 2069 while 1/1/70 is 1970).
5076
5077        The string supplied in str_ is used by operator() to decide whether
5078        the pair of strings supplied to it constitute a valid range. If
5079        prefix_ is true, the first value in a range must begin with str_ (and
5080        the second value may optionally begin with str_); if prefix_ is false,
5081        the second value in a range must end with str_ (and the first value
5082        may optionally end with str_).
5083
5084        If str_ is empty, the setting of prefix_ is irrelevant, and no special
5085        strings are required at the start or end of the strings defining the
5086        range.
5087
5088        The remainder of both strings defining the endpoints must be valid
5089        dates.
5090
5091        For example, if str_ is "created:" and prefix_ is true, and the
5092        range processor has been added to the queryparser, the queryparser
5093        will accept "created:1/1/2000..31/12/2001".
5094        """
5095        _xapian.DateValueRangeProcessor_swiginit(self, _xapian.new_DateValueRangeProcessor(*args))
5096    __swig_destroy__ = _xapian.delete_DateValueRangeProcessor
5097DateValueRangeProcessor_swigregister = _xapian.DateValueRangeProcessor_swigregister
5098DateValueRangeProcessor_swigregister(DateValueRangeProcessor)
5099
5100class NumberValueRangeProcessor(StringValueRangeProcessor):
5101    """
5102
5103
5104    Handle a number range.
5105
5106    This class must be used on values which have been encoded using
5107    Xapian::sortable_serialise() which turns numbers into strings which
5108    will sort in the same order as the numbers (the same values can be
5109    used to implement a numeric sort).
5110
5111    Deprecated Use Xapian::NumberRangeProcessor instead (added in 1.3.6).
5112
5113    """
5114
5115    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5116    __repr__ = _swig_repr
5117
5118    def __init__(self, *args):
5119        """
5120
5121
5122        Constructor.
5123
5124        Xapian::NumberValueRangeProcessor::NumberValueRangeProcessor(Xapian::valueno
5125        slot_, const std::string &str_, bool prefix_=true)
5126
5127        Parameters:
5128        -----------
5129
5130        slot_:  The value number to return from operator().
5131
5132        str_:  A string to look for to recognise values as belonging to this
5133        numeric range.
5134
5135        prefix_:  Whether to look for the string at the start or end of the
5136        values. If true, the string is a prefix; if false, the string is a
5137        suffix (default: true).
5138
5139        The string supplied in str_ is used by operator() to decide whether
5140        the pair of strings supplied to it constitute a valid range. If
5141        prefix_ is true, the first value in a range must begin with str_ (and
5142        the second value may optionally begin with str_); if prefix_ is false,
5143        the second value in a range must end with str_ (and the first value
5144        may optionally end with str_).
5145
5146        If str_ is empty, the setting of prefix_ is irrelevant, and no special
5147        strings are required at the start or end of the strings defining the
5148        range.
5149
5150        The remainder of both strings defining the endpoints must be valid
5151        floating point numbers. (FIXME: define format recognised).
5152
5153        For example, if str_ is "$" and prefix_ is true, and the range
5154        processor has been added to the queryparser, the queryparser will
5155        accept "$10..50" or "$10..$50", but not "10..50" or "10..$50"
5156        as valid ranges. If str_ is "kg" and prefix_ is false, the
5157        queryparser will accept "10..50kg" or "10kg..50kg", but not
5158        "10..50" or "10kg..50" as valid ranges.
5159        """
5160        _xapian.NumberValueRangeProcessor_swiginit(self, _xapian.new_NumberValueRangeProcessor(*args))
5161    __swig_destroy__ = _xapian.delete_NumberValueRangeProcessor
5162NumberValueRangeProcessor_swigregister = _xapian.NumberValueRangeProcessor_swigregister
5163NumberValueRangeProcessor_swigregister(NumberValueRangeProcessor)
5164
5165class FieldProcessor(object):
5166    """
5167
5168
5169    Base class for field processors.
5170    """
5171
5172    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5173    __repr__ = _swig_repr
5174
5175    def __init__(self):
5176        """
5177
5178
5179        Default constructor.
5180
5181        Xapian::FieldProcessor::FieldProcessor()
5182        """
5183        if self.__class__ == FieldProcessor:
5184            _self = None
5185        else:
5186            _self = self
5187        _xapian.FieldProcessor_swiginit(self, _xapian.new_FieldProcessor(_self, ))
5188    __swig_destroy__ = _xapian.delete_FieldProcessor
5189
5190    def release(self):
5191        """
5192
5193
5194        Start reference counting this object.
5195
5196        const FieldProcessor* Xapian::FieldProcessor::release() const
5197
5198        You can hand ownership of a dynamically allocated FieldProcessor
5199        object to Xapian by calling release() and then passing the object to a
5200        Xapian method. Xapian will arrange to delete the object once it is no
5201        longer required.
5202        """
5203        return _xapian.FieldProcessor_release(self)
5204
5205    def __disown__(self):
5206        self.this.disown()
5207        _xapian.disown_FieldProcessor(self)
5208        return weakref_proxy(self)
5209FieldProcessor.__call__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.FieldProcessor___call__)
5210FieldProcessor.release = _xapian.SWIG_PyInstanceMethod_New(_xapian.FieldProcessor_release)
5211FieldProcessor_swigregister = _xapian.FieldProcessor_swigregister
5212FieldProcessor_swigregister(FieldProcessor)
5213
5214class QueryParser(object):
5215    """
5216
5217
5218    Build a Xapian::Query object from a user query string.
5219    """
5220
5221    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5222    __repr__ = _swig_repr
5223    FLAG_BOOLEAN = _xapian.QueryParser_FLAG_BOOLEAN
5224    FLAG_PHRASE = _xapian.QueryParser_FLAG_PHRASE
5225    FLAG_LOVEHATE = _xapian.QueryParser_FLAG_LOVEHATE
5226    FLAG_BOOLEAN_ANY_CASE = _xapian.QueryParser_FLAG_BOOLEAN_ANY_CASE
5227    FLAG_WILDCARD = _xapian.QueryParser_FLAG_WILDCARD
5228    FLAG_PURE_NOT = _xapian.QueryParser_FLAG_PURE_NOT
5229    FLAG_PARTIAL = _xapian.QueryParser_FLAG_PARTIAL
5230    FLAG_SPELLING_CORRECTION = _xapian.QueryParser_FLAG_SPELLING_CORRECTION
5231    FLAG_SYNONYM = _xapian.QueryParser_FLAG_SYNONYM
5232    FLAG_AUTO_SYNONYMS = _xapian.QueryParser_FLAG_AUTO_SYNONYMS
5233    FLAG_AUTO_MULTIWORD_SYNONYMS = _xapian.QueryParser_FLAG_AUTO_MULTIWORD_SYNONYMS
5234    FLAG_CJK_NGRAM = _xapian.QueryParser_FLAG_CJK_NGRAM
5235    FLAG_ACCUMULATE = _xapian.QueryParser_FLAG_ACCUMULATE
5236    FLAG_DEFAULT = _xapian.QueryParser_FLAG_DEFAULT
5237    STEM_NONE = _xapian.QueryParser_STEM_NONE
5238    STEM_SOME = _xapian.QueryParser_STEM_SOME
5239    STEM_ALL = _xapian.QueryParser_STEM_ALL
5240    STEM_ALL_Z = _xapian.QueryParser_STEM_ALL_Z
5241    STEM_SOME_FULL_POS = _xapian.QueryParser_STEM_SOME_FULL_POS
5242
5243    def __init__(self):
5244        """
5245
5246
5247        Default constructor.
5248
5249        Xapian::QueryParser::QueryParser()
5250        """
5251        _xapian.QueryParser_swiginit(self, _xapian.new_QueryParser())
5252    __swig_destroy__ = _xapian.delete_QueryParser
5253
5254    def set_stemmer(self, stemmer):
5255        """
5256
5257
5258        Set the stemmer.
5259
5260        void Xapian::QueryParser::set_stemmer(const Xapian::Stem &stemmer)
5261
5262        This sets the stemming algorithm which will be used by the query
5263        parser. The stemming algorithm will be used according to the stemming
5264        strategy set by set_stemming_strategy(). As of 1.3.1, this defaults to
5265        STEM_SOME, but in earlier versions the default was STEM_NONE. If you
5266        want to work with older versions, you should explicitly set a stemming
5267        strategy as well as setting a stemmer, otherwise your stemmer won't
5268        actually be used.
5269
5270        Parameters:
5271        -----------
5272
5273        stemmer:  The Xapian::Stem object to set.
5274        """
5275        return _xapian.QueryParser_set_stemmer(self, stemmer)
5276
5277
5278    def set_stemming_strategy(self, strategy):
5279        """
5280
5281
5282        Set the stemming strategy.
5283
5284        void Xapian::QueryParser::set_stemming_strategy(stem_strategy
5285        strategy)
5286
5287        This controls how the query parser will apply the stemming algorithm.
5288        Note that the stemming algorithm is only applied to words in free-text
5289        fields - boolean filter terms are never stemmed.
5290
5291        Parameters:
5292        -----------
5293
5294        strategy:  The strategy to use - possible values are: STEM_NONE: Don't
5295        perform any stemming. (default in Xapian <= 1.3.0)
5296
5297        STEM_SOME: Stem all terms except for those which start with a capital
5298        letter, or are followed by certain characters (currently: (/@<>=*[{"
5299        ), or are used with operators which need positional information.
5300        Stemmed terms are prefixed with 'Z'. (default in Xapian >= 1.3.1)
5301
5302        STEM_SOME_FULL_POS: Like STEM_SOME but also stems terms used with
5303        operators which need positional information. Added in Xapian 1.4.8.
5304
5305        STEM_ALL: Stem all terms (note: no 'Z' prefix is added).
5306
5307        STEM_ALL_Z: Stem all terms (note: 'Z' prefix is added). (new in Xapian
5308        1.2.11 and 1.3.1)
5309        """
5310        return _xapian.QueryParser_set_stemming_strategy(self, strategy)
5311
5312
5313    def set_stopper(self, stop=None):
5314        """
5315
5316
5317        Set the stopper.
5318
5319        void Xapian::QueryParser::set_stopper(const Stopper *stop=NULL)
5320
5321        Parameters:
5322        -----------
5323
5324        stop:  The Stopper object to set (default NULL, which means no
5325        stopwords).
5326        """
5327        return _xapian.QueryParser_set_stopper(self, stop)
5328
5329
5330    def set_default_op(self, default_op):
5331        """
5332
5333
5334        Set the default operator.
5335
5336        void Xapian::QueryParser::set_default_op(Query::op default_op)
5337
5338        Parameters:
5339        -----------
5340
5341        default_op:  The operator to use to combine non-filter query items
5342        when no explicit operator is used.
5343
5344        So for example, 'weather forecast' is parsed as if it were 'weather OR
5345        forecast' by default.
5346
5347        The most useful values for this are OP_OR (the default) and OP_AND.
5348        OP_NEAR, OP_PHRASE, OP_ELITE_SET, OP_SYNONYM and OP_MAX are also
5349        permitted. Passing other values will result in InvalidArgumentError
5350        being thrown.
5351        """
5352        return _xapian.QueryParser_set_default_op(self, default_op)
5353
5354
5355    def get_default_op(self):
5356        """
5357
5358
5359        Get the current default operator.
5360
5361        Query::op Xapian::QueryParser::get_default_op() const
5362        """
5363        return _xapian.QueryParser_get_default_op(self)
5364
5365
5366    def set_database(self, db):
5367        """
5368
5369
5370        Specify the database being searched.
5371
5372        void Xapian::QueryParser::set_database(const Database &db)
5373
5374        Parameters:
5375        -----------
5376
5377        db:  The database to use for spelling correction
5378        (FLAG_SPELLING_CORRECTION), and synonyms (FLAG_SYNONYM,
5379        FLAG_AUTO_SYNONYMS, and FLAG_AUTO_MULTIWORD_SYNONYMS).
5380        """
5381        return _xapian.QueryParser_set_database(self, db)
5382
5383
5384    def set_max_expansion(self, *args):
5385        """
5386
5387
5388        Specify the maximum expansion of a wildcard and/or partial term.
5389
5390        void Xapian::QueryParser::set_max_expansion(Xapian::termcount
5391        max_expansion, int max_type=Xapian::Query::WILDCARD_LIMIT_ERROR,
5392        unsigned flags=FLAG_WILDCARD|FLAG_PARTIAL)
5393
5394        Note: you must also set FLAG_WILDCARD and/or FLAG_PARTIAL in the flags
5395        parameter to  parse_query() for this setting to have anything to
5396        affect.
5397
5398        If you don't call this method, the default settings are no limit on
5399        wildcard expansion, and partial terms expanding to the most frequent
5400        100 terms - i.e. as if you'd called:
5401
5402        set_max_expansion(0); set_max_expansion(100,
5403        Xapian::Query::WILDCARD_LIMIT_MOST_FREQUENT,
5404        Xapian::QueryParser::FLAG_PARTIAL);
5405
5406        Parameters:
5407        -----------
5408
5409        max_expansion:  The maximum number of terms each wildcard in the query
5410        can expand to, or 0 for no limit (which is the default).
5411
5412        max_type:    Xapian::Query::WILDCARD_LIMIT_ERROR,
5413        Xapian::Query::WILDCARD_LIMIT_FIRST or
5414        Xapian::Query::WILDCARD_LIMIT_MOST_FREQUENT (default:
5415        Xapian::Query::WILDCARD_LIMIT_ERROR).
5416
5417        flags:  What to set the limit for (default:
5418        FLAG_WILDCARD|FLAG_PARTIAL, setting the limit for both wildcards and
5419        partial terms).
5420
5421        1.3.3
5422        """
5423        return _xapian.QueryParser_set_max_expansion(self, *args)
5424
5425
5426    def set_max_wildcard_expansion(self, arg2):
5427        """
5428
5429
5430        Specify the maximum expansion of a wildcard.
5431
5432        void
5433        Xapian::QueryParser::set_max_wildcard_expansion(Xapian::termcount)
5434
5435        If any wildcard expands to more than max_expansion terms, an exception
5436        will be thrown.
5437
5438        This method is provided for API compatibility with Xapian 1.2.x and is
5439        deprecated - replace it with:
5440
5441        set_max_wildcard_expansion(max_expansion,
5442        Xapian::Query::WILDCARD_LIMIT_ERROR,
5443        Xapian::QueryParser::FLAG_WILDCARD);
5444        """
5445        return _xapian.QueryParser_set_max_wildcard_expansion(self, arg2)
5446
5447
5448    def parse_query(self, *args):
5449        """
5450
5451
5452        Parse a query.
5453
5454        Query Xapian::QueryParser::parse_query(const std::string
5455        &query_string, unsigned flags=FLAG_DEFAULT, const std::string
5456        &default_prefix=std::string())
5457
5458        Parameters:
5459        -----------
5460
5461        query_string:  A free-text query as entered by a user
5462
5463        flags:  Zero or more QueryParser::feature_flag specifying what
5464        features the QueryParser should support. Combine multiple values with
5465        bitwise-or (|) (default FLAG_DEFAULT).
5466
5467        default_prefix:  The default term prefix to use (default none). For
5468        example, you can pass "A" when parsing an "Author" field.
5469
5470        Parameters:
5471        -----------
5472
5473        If:  the query string can't be parsed, then Xapian::QueryParserError
5474        is thrown. You can get an English error message to report to the user
5475        by catching it and calling get_msg() on the caught exception. The
5476        current possible values (in case you want to translate them) are:
5477
5478        Unknown range operation
5479
5480        parse error
5481
5482        Syntax: <expression> AND <expression>
5483
5484        Syntax: <expression> AND NOT <expression>
5485
5486        Syntax: <expression> NOT <expression>
5487
5488        Syntax: <expression> OR <expression>
5489
5490        Syntax: <expression> XOR <expression>
5491        """
5492        return _xapian.QueryParser_parse_query(self, *args)
5493
5494
5495    def add_prefix(self, *args):
5496        """
5497
5498
5499        Register a FieldProcessor.
5500
5501        void Xapian::QueryParser::add_prefix(const std::string &field,
5502        Xapian::FieldProcessor *proc)
5503        """
5504        return _xapian.QueryParser_add_prefix(self, *args)
5505
5506
5507    def add_boolean_prefix(self, *args):
5508        """
5509
5510
5511        Register a FieldProcessor for a boolean prefix.
5512
5513        void Xapian::QueryParser::add_boolean_prefix(const std::string &field,
5514        Xapian::FieldProcessor *proc, bool exclusive)
5515
5516        This is an older version of this method - use the version with the
5517        grouping parameter in preference to this one.
5518        """
5519        return _xapian.QueryParser_add_boolean_prefix(self, *args)
5520
5521
5522    def _stoplist_begin(self):
5523        """
5524
5525
5526        Begin iterator over terms omitted from the query as stopwords.
5527
5528        TermIterator Xapian::QueryParser::stoplist_begin() const
5529        """
5530        return _xapian.QueryParser__stoplist_begin(self)
5531
5532
5533    def _stoplist_end(self):
5534        """
5535
5536
5537        End iterator over terms omitted from the query as stopwords.
5538
5539        TermIterator Xapian::QueryParser::stoplist_end() const
5540        """
5541        return _xapian.QueryParser__stoplist_end(self)
5542
5543
5544    def _unstem_begin(self, term):
5545        """
5546
5547
5548        Begin iterator over unstemmed forms of the given stemmed query term.
5549
5550        TermIterator Xapian::QueryParser::unstem_begin(const std::string
5551        &term) const
5552        """
5553        return _xapian.QueryParser__unstem_begin(self, term)
5554
5555
5556    def _unstem_end(self, arg2):
5557        """
5558
5559
5560        End iterator over unstemmed forms of the given stemmed query term.
5561
5562        TermIterator Xapian::QueryParser::unstem_end(const std::string &)
5563        const
5564        """
5565        return _xapian.QueryParser__unstem_end(self, arg2)
5566
5567
5568    def add_rangeprocessor(self, range_proc, grouping=None):
5569        """
5570
5571
5572        Register a RangeProcessor.
5573
5574        void Xapian::QueryParser::add_rangeprocessor(Xapian::RangeProcessor
5575        *range_proc, const std::string *grouping=NULL)
5576        """
5577        return _xapian.QueryParser_add_rangeprocessor(self, range_proc, grouping)
5578
5579
5580    def add_valuerangeprocessor(self, vrproc):
5581        """
5582
5583
5584        Register a ValueRangeProcessor.
5585
5586        void
5587        Xapian::QueryParser::add_valuerangeprocessor(Xapian::ValueRangeProcessor
5588        *vrproc)
5589
5590        This method is provided for API compatibility with Xapian 1.2.x and is
5591        deprecated - use  add_rangeprocessor() with a RangeProcessor instead.
5592
5593        Compatibility shim.
5594        """
5595        return _xapian.QueryParser_add_valuerangeprocessor(self, vrproc)
5596
5597
5598    def get_corrected_query_string(self):
5599        """
5600
5601
5602        Get the spelling-corrected query string.
5603
5604        std::string Xapian::QueryParser::get_corrected_query_string() const
5605
5606        This will only be set if FLAG_SPELLING_CORRECTION is specified when
5607        QueryParser::parse_query() was last called.
5608
5609        If there were no corrections, an empty string is returned.
5610        """
5611        return _xapian.QueryParser_get_corrected_query_string(self)
5612
5613
5614    def __str__(self):
5615        """
5616
5617
5618        Return a string describing this object.
5619
5620        std::string Xapian::QueryParser::get_description() const
5621        """
5622        return _xapian.QueryParser___str__(self)
5623
5624QueryParser.set_stemmer = _xapian.SWIG_PyInstanceMethod_New(_xapian.QueryParser_set_stemmer)
5625QueryParser.set_stemming_strategy = _xapian.SWIG_PyInstanceMethod_New(_xapian.QueryParser_set_stemming_strategy)
5626QueryParser.set_stopper = _xapian.SWIG_PyInstanceMethod_New(_xapian.QueryParser_set_stopper)
5627QueryParser.set_default_op = _xapian.SWIG_PyInstanceMethod_New(_xapian.QueryParser_set_default_op)
5628QueryParser.get_default_op = _xapian.SWIG_PyInstanceMethod_New(_xapian.QueryParser_get_default_op)
5629QueryParser.set_database = _xapian.SWIG_PyInstanceMethod_New(_xapian.QueryParser_set_database)
5630QueryParser.set_max_expansion = _xapian.SWIG_PyInstanceMethod_New(_xapian.QueryParser_set_max_expansion)
5631QueryParser.set_max_wildcard_expansion = _xapian.SWIG_PyInstanceMethod_New(_xapian.QueryParser_set_max_wildcard_expansion)
5632QueryParser.parse_query = _xapian.SWIG_PyInstanceMethod_New(_xapian.QueryParser_parse_query)
5633QueryParser.add_prefix = _xapian.SWIG_PyInstanceMethod_New(_xapian.QueryParser_add_prefix)
5634QueryParser.add_boolean_prefix = _xapian.SWIG_PyInstanceMethod_New(_xapian.QueryParser_add_boolean_prefix)
5635QueryParser._stoplist_begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.QueryParser__stoplist_begin)
5636QueryParser._stoplist_end = _xapian.SWIG_PyInstanceMethod_New(_xapian.QueryParser__stoplist_end)
5637QueryParser._unstem_begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.QueryParser__unstem_begin)
5638QueryParser._unstem_end = _xapian.SWIG_PyInstanceMethod_New(_xapian.QueryParser__unstem_end)
5639QueryParser.add_rangeprocessor = _xapian.SWIG_PyInstanceMethod_New(_xapian.QueryParser_add_rangeprocessor)
5640QueryParser.add_valuerangeprocessor = _xapian.SWIG_PyInstanceMethod_New(_xapian.QueryParser_add_valuerangeprocessor)
5641QueryParser.get_corrected_query_string = _xapian.SWIG_PyInstanceMethod_New(_xapian.QueryParser_get_corrected_query_string)
5642QueryParser.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.QueryParser___str__)
5643QueryParser_swigregister = _xapian.QueryParser_swigregister
5644QueryParser_swigregister(QueryParser)
5645
5646
5647def sortable_serialise(value):
5648    return _xapian.sortable_serialise(value)
5649sortable_serialise = _xapian.sortable_serialise
5650
5651def sortable_unserialise(serialised):
5652    return _xapian.sortable_unserialise(serialised)
5653sortable_unserialise = _xapian.sortable_unserialise
5654class ValueSetMatchDecider(MatchDecider):
5655    """
5656
5657
5658    MatchDecider filtering results based on whether document values are in
5659    a user- defined set.
5660    """
5661
5662    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5663    __repr__ = _swig_repr
5664
5665    def __init__(self, slot, inclusive_):
5666        """
5667
5668
5669        Construct a ValueSetMatchDecider.
5670
5671        Xapian::ValueSetMatchDecider::ValueSetMatchDecider(Xapian::valueno
5672        slot, bool inclusive_)
5673
5674        Parameters:
5675        -----------
5676
5677        slot:  The value slot number to look in.
5678
5679        inclusive_:  If true, match decider accepts documents which have a
5680        value in the specified slot which is a member of the test set; if
5681        false, match decider accepts documents which do not have a value in
5682        the specified slot.
5683        """
5684        _xapian.ValueSetMatchDecider_swiginit(self, _xapian.new_ValueSetMatchDecider(slot, inclusive_))
5685
5686    def add_value(self, value):
5687        """
5688
5689
5690        Add a value to the test set.
5691
5692        void Xapian::ValueSetMatchDecider::add_value(const std::string &value)
5693
5694        Parameters:
5695        -----------
5696
5697        value:  The value to add to the test set.
5698        """
5699        return _xapian.ValueSetMatchDecider_add_value(self, value)
5700
5701
5702    def remove_value(self, value):
5703        """
5704
5705
5706        Remove a value from the test set.
5707
5708        void Xapian::ValueSetMatchDecider::remove_value(const std::string
5709        &value)
5710
5711        Parameters:
5712        -----------
5713
5714        value:  The value to remove from the test set.
5715        """
5716        return _xapian.ValueSetMatchDecider_remove_value(self, value)
5717
5718    __swig_destroy__ = _xapian.delete_ValueSetMatchDecider
5719ValueSetMatchDecider.add_value = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValueSetMatchDecider_add_value)
5720ValueSetMatchDecider.remove_value = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValueSetMatchDecider_remove_value)
5721ValueSetMatchDecider_swigregister = _xapian.ValueSetMatchDecider_swigregister
5722ValueSetMatchDecider_swigregister(ValueSetMatchDecider)
5723
5724class Weight(object):
5725    """
5726
5727
5728    Abstract base class for weighting schemes.
5729    """
5730
5731    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5732
5733    def __init__(self, *args, **kwargs):
5734        raise AttributeError("No constructor defined - class is abstract")
5735    __repr__ = _swig_repr
5736    TWO_STAGE_SMOOTHING = _xapian.Weight_TWO_STAGE_SMOOTHING
5737    DIRICHLET_SMOOTHING = _xapian.Weight_DIRICHLET_SMOOTHING
5738    ABSOLUTE_DISCOUNT_SMOOTHING = _xapian.Weight_ABSOLUTE_DISCOUNT_SMOOTHING
5739    JELINEK_MERCER_SMOOTHING = _xapian.Weight_JELINEK_MERCER_SMOOTHING
5740    DIRICHLET_PLUS_SMOOTHING = _xapian.Weight_DIRICHLET_PLUS_SMOOTHING
5741    __swig_destroy__ = _xapian.delete_Weight
5742
5743    def name(self):
5744        """
5745
5746
5747        Return the name of this weighting scheme.
5748
5749        virtual std::string Xapian::Weight::name() const
5750
5751        This name is used by the remote backend. It is passed along with the
5752        serialised parameters to the remote server so that it knows which
5753        class to create.
5754
5755        Return the full namespace-qualified name of your class here - if your
5756        class is called FooWeight, return "FooWeight" from this method (
5757        Xapian::BM25Weight returns "Xapian::BM25Weight" here).
5758
5759        If you don't want to support the remote backend, you can use the
5760        default implementation which simply returns an empty string.
5761        """
5762        return _xapian.Weight_name(self)
5763
5764
5765    def get_sumpart(self, wdf, doclen, uniqterms):
5766        """
5767
5768
5769        Calculate the weight contribution for this object's term to a
5770        document.
5771
5772        virtual double Xapian::Weight::get_sumpart(Xapian::termcount wdf,
5773        Xapian::termcount doclen, Xapian::termcount uniqterms) const =0
5774
5775        The parameters give information about the document which may be used
5776        in the calculations:
5777
5778        Parameters:
5779        -----------
5780
5781        wdf:  The within document frequency of the term in the document.
5782
5783        doclen:  The document's length (unnormalised).
5784
5785        uniqterms:  Number of unique terms in the document (used for absolute
5786        smoothing).
5787        """
5788        return _xapian.Weight_get_sumpart(self, wdf, doclen, uniqterms)
5789
5790
5791    def get_maxpart(self):
5792        """
5793
5794
5795        Return an upper bound on what get_sumpart() can return for any
5796        document.
5797
5798        virtual double Xapian::Weight::get_maxpart() const =0
5799
5800        This information is used by the matcher to perform various
5801        optimisations, so strive to make the bound as tight as possible.
5802        """
5803        return _xapian.Weight_get_maxpart(self)
5804
5805
5806    def get_sumextra(self, doclen, uniqterms):
5807        """
5808
5809
5810        Calculate the term-independent weight component for a document.
5811
5812        virtual double Xapian::Weight::get_sumextra(Xapian::termcount doclen,
5813        Xapian::termcount uniqterms) const =0
5814
5815        The parameter gives information about the document which may be used
5816        in the calculations:
5817
5818        Parameters:
5819        -----------
5820
5821        doclen:  The document's length (unnormalised).
5822
5823        uniqterms:  The number of unique terms in the document.
5824        """
5825        return _xapian.Weight_get_sumextra(self, doclen, uniqterms)
5826
5827
5828    def get_maxextra(self):
5829        """
5830
5831
5832        Return an upper bound on what get_sumextra() can return for any
5833        document.
5834
5835        virtual double Xapian::Weight::get_maxextra() const =0
5836
5837        This information is used by the matcher to perform various
5838        optimisations, so strive to make the bound as tight as possible.
5839        """
5840        return _xapian.Weight_get_maxextra(self)
5841
5842Weight.name = _xapian.SWIG_PyInstanceMethod_New(_xapian.Weight_name)
5843Weight.get_sumpart = _xapian.SWIG_PyInstanceMethod_New(_xapian.Weight_get_sumpart)
5844Weight.get_maxpart = _xapian.SWIG_PyInstanceMethod_New(_xapian.Weight_get_maxpart)
5845Weight.get_sumextra = _xapian.SWIG_PyInstanceMethod_New(_xapian.Weight_get_sumextra)
5846Weight.get_maxextra = _xapian.SWIG_PyInstanceMethod_New(_xapian.Weight_get_maxextra)
5847Weight_swigregister = _xapian.Weight_swigregister
5848Weight_swigregister(Weight)
5849
5850class BoolWeight(Weight):
5851    """
5852
5853
5854    Class implementing a "boolean" weighting scheme.
5855
5856    This weighting scheme gives all documents zero weight.
5857    """
5858
5859    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5860    __repr__ = _swig_repr
5861
5862    def __init__(self):
5863        """
5864
5865
5866        Construct a BoolWeight.
5867
5868        Xapian::BoolWeight::BoolWeight()
5869        """
5870        _xapian.BoolWeight_swiginit(self, _xapian.new_BoolWeight())
5871    __swig_destroy__ = _xapian.delete_BoolWeight
5872BoolWeight_swigregister = _xapian.BoolWeight_swigregister
5873BoolWeight_swigregister(BoolWeight)
5874
5875class TfIdfWeight(Weight):
5876    """
5877
5878
5879    Xapian::Weight subclass implementing the tf-idf weighting scheme.
5880    """
5881
5882    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5883    __repr__ = _swig_repr
5884
5885    def __init__(self, *args):
5886        """
5887
5888
5889        Construct a TfIdfWeight using the default normalizations ("ntn").
5890
5891        Xapian::TfIdfWeight::TfIdfWeight()
5892        """
5893        _xapian.TfIdfWeight_swiginit(self, _xapian.new_TfIdfWeight(*args))
5894    __swig_destroy__ = _xapian.delete_TfIdfWeight
5895TfIdfWeight_swigregister = _xapian.TfIdfWeight_swigregister
5896TfIdfWeight_swigregister(TfIdfWeight)
5897
5898class BM25Weight(Weight):
5899    """
5900
5901
5902    Xapian::Weight subclass implementing the BM25 probabilistic formula.
5903
5904    """
5905
5906    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5907    __repr__ = _swig_repr
5908
5909    def __init__(self, *args):
5910        """Xapian::BM25Weight::BM25Weight() """
5911        _xapian.BM25Weight_swiginit(self, _xapian.new_BM25Weight(*args))
5912    __swig_destroy__ = _xapian.delete_BM25Weight
5913BM25Weight_swigregister = _xapian.BM25Weight_swigregister
5914BM25Weight_swigregister(BM25Weight)
5915
5916class BM25PlusWeight(Weight):
5917    """
5918
5919
5920    Xapian::Weight subclass implementing the BM25+ probabilistic formula.
5921
5922    """
5923
5924    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5925    __repr__ = _swig_repr
5926
5927    def __init__(self, *args):
5928        """Xapian::BM25PlusWeight::BM25PlusWeight() """
5929        _xapian.BM25PlusWeight_swiginit(self, _xapian.new_BM25PlusWeight(*args))
5930    __swig_destroy__ = _xapian.delete_BM25PlusWeight
5931BM25PlusWeight_swigregister = _xapian.BM25PlusWeight_swigregister
5932BM25PlusWeight_swigregister(BM25PlusWeight)
5933
5934class TradWeight(Weight):
5935    """
5936
5937
5938    Xapian::Weight subclass implementing the traditional probabilistic
5939    formula.
5940
5941    This class implements the "traditional" Probabilistic Weighting
5942    scheme, as described by the early papers on Probabilistic Retrieval.
5943    BM25 generally gives better results.
5944
5945    TradWeight(k) is equivalent to BM25Weight(k, 0, 0, 1, 0), except that
5946    the latter returns weights (k+1) times larger.
5947    """
5948
5949    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5950    __repr__ = _swig_repr
5951
5952    def __init__(self, k=1.0):
5953        """
5954
5955
5956        Construct a TradWeight.
5957
5958        Xapian::TradWeight::TradWeight(double k=1.0)
5959
5960        Parameters:
5961        -----------
5962
5963        k:  A non-negative parameter controlling how influential within-
5964        document- frequency (wdf) and document length are. k=0 means that wdf
5965        and document length don't affect the weights. The larger k is, the
5966        more they do. (default 1)
5967        """
5968        _xapian.TradWeight_swiginit(self, _xapian.new_TradWeight(k))
5969    __swig_destroy__ = _xapian.delete_TradWeight
5970TradWeight_swigregister = _xapian.TradWeight_swigregister
5971TradWeight_swigregister(TradWeight)
5972
5973class InL2Weight(Weight):
5974    """
5975
5976
5977    This class implements the InL2 weighting scheme.
5978
5979    InL2 is a representative scheme of the Divergence from Randomness
5980    Framework by Gianni Amati.
5981
5982    This weighting scheme is useful for tasks that require early
5983    precision.
5984
5985    It uses the Inverse document frequency model (In), the Laplace method
5986    to find the aftereffect of sampling (L) and the second wdf
5987    normalization proposed by Amati to normalize the wdf in the document
5988    to the length of the document (H2).
5989
5990    For more information about the DFR Framework and the InL2 scheme,
5991    please refer to: Gianni Amati and Cornelis Joost Van Rijsbergen
5992    Probabilistic models of information retrieval based on measuring the
5993    divergence from randomness ACM Transactions on Information Systems
5994    (TOIS) 20, (4), 2002, pp. 357-389.
5995    """
5996
5997    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
5998    __repr__ = _swig_repr
5999
6000    def __init__(self, *args):
6001        """Xapian::InL2Weight::InL2Weight() """
6002        _xapian.InL2Weight_swiginit(self, _xapian.new_InL2Weight(*args))
6003    __swig_destroy__ = _xapian.delete_InL2Weight
6004InL2Weight_swigregister = _xapian.InL2Weight_swigregister
6005InL2Weight_swigregister(InL2Weight)
6006
6007class IfB2Weight(Weight):
6008    """
6009
6010
6011    This class implements the IfB2 weighting scheme.
6012
6013    IfB2 is a representative scheme of the Divergence from Randomness
6014    Framework by Gianni Amati.
6015
6016    It uses the Inverse term frequency model (If), the Bernoulli method to
6017    find the aftereffect of sampling (B) and the second wdf normalization
6018    proposed by Amati to normalize the wdf in the document to the length
6019    of the document (H2).
6020
6021    For more information about the DFR Framework and the IfB2 scheme,
6022    please refer to: Gianni Amati and Cornelis Joost Van Rijsbergen
6023    Probabilistic models of information retrieval based on measuring the
6024    divergence from randomness ACM Transactions on Information Systems
6025    (TOIS) 20, (4), 2002, pp. 357-389.
6026    """
6027
6028    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
6029    __repr__ = _swig_repr
6030
6031    def __init__(self, *args):
6032        """Xapian::IfB2Weight::IfB2Weight() """
6033        _xapian.IfB2Weight_swiginit(self, _xapian.new_IfB2Weight(*args))
6034    __swig_destroy__ = _xapian.delete_IfB2Weight
6035IfB2Weight_swigregister = _xapian.IfB2Weight_swigregister
6036IfB2Weight_swigregister(IfB2Weight)
6037
6038class IneB2Weight(Weight):
6039    """
6040
6041
6042    This class implements the IneB2 weighting scheme.
6043
6044    IneB2 is a representative scheme of the Divergence from Randomness
6045    Framework by Gianni Amati.
6046
6047    It uses the Inverse expected document frequency model (Ine), the
6048    Bernoulli method to find the aftereffect of sampling (B) and the
6049    second wdf normalization proposed by Amati to normalize the wdf in the
6050    document to the length of the document (H2).
6051
6052    For more information about the DFR Framework and the IneB2 scheme,
6053    please refer to: Gianni Amati and Cornelis Joost Van Rijsbergen
6054    Probabilistic models of information retrieval based on measuring the
6055    divergence from randomness ACM Transactions on Information Systems
6056    (TOIS) 20, (4), 2002, pp. 357-389.
6057    """
6058
6059    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
6060    __repr__ = _swig_repr
6061
6062    def __init__(self, *args):
6063        """Xapian::IneB2Weight::IneB2Weight() """
6064        _xapian.IneB2Weight_swiginit(self, _xapian.new_IneB2Weight(*args))
6065    __swig_destroy__ = _xapian.delete_IneB2Weight
6066IneB2Weight_swigregister = _xapian.IneB2Weight_swigregister
6067IneB2Weight_swigregister(IneB2Weight)
6068
6069class BB2Weight(Weight):
6070    """
6071
6072
6073    This class implements the BB2 weighting scheme.
6074
6075    BB2 is a representative scheme of the Divergence from Randomness
6076    Framework by Gianni Amati.
6077
6078    It uses the Bose-Einstein probabilistic distribution (B) along with
6079    Stirling's power approximation, the Bernoulli method to find the
6080    aftereffect of sampling (B) and the second wdf normalization proposed
6081    by Amati to normalize the wdf in the document to the length of the
6082    document (H2).
6083
6084    For more information about the DFR Framework and the BB2 scheme,
6085    please refer to : Gianni Amati and Cornelis Joost Van Rijsbergen
6086    Probabilistic models of information retrieval based on measuring the
6087    divergence from randomness ACM Transactions on Information Systems
6088    (TOIS) 20, (4), 2002, pp. 357-389.
6089    """
6090
6091    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
6092    __repr__ = _swig_repr
6093
6094    def __init__(self, *args):
6095        """Xapian::BB2Weight::BB2Weight() """
6096        _xapian.BB2Weight_swiginit(self, _xapian.new_BB2Weight(*args))
6097    __swig_destroy__ = _xapian.delete_BB2Weight
6098BB2Weight_swigregister = _xapian.BB2Weight_swigregister
6099BB2Weight_swigregister(BB2Weight)
6100
6101class DLHWeight(Weight):
6102    """
6103
6104
6105    This class implements the DLH weighting scheme, which is a
6106    representative scheme of the Divergence from Randomness Framework by
6107    Gianni Amati.
6108
6109    This is a parameter free weighting scheme and it should be used with
6110    query expansion to obtain better results. It uses the HyperGeometric
6111    Probabilistic model and Laplace's normalization to calculate the risk
6112    gain.
6113
6114    For more information about the DFR Framework and the DLH scheme,
6115    please refer to : a.) Gianni Amati and Cornelis Joost Van Rijsbergen
6116    Probabilistic models of information retrieval based on measuring the
6117    divergence from randomness ACM Transactions on Information Systems
6118    (TOIS) 20, (4), 2002, pp. 357-389. b.) FUB, IASI-CNR and University of
6119    Tor Vergata at TREC 2007 Blog Track. G. Amati and E. Ambrosi and M.
6120    Bianchi and C. Gaibisso and G. Gambosi. Proceedings of the 16th Text
6121    REtrieval Conference (TREC-2007), 2008.
6122    """
6123
6124    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
6125    __repr__ = _swig_repr
6126
6127    def __init__(self):
6128        """Xapian::DLHWeight::DLHWeight() """
6129        _xapian.DLHWeight_swiginit(self, _xapian.new_DLHWeight())
6130    __swig_destroy__ = _xapian.delete_DLHWeight
6131DLHWeight_swigregister = _xapian.DLHWeight_swigregister
6132DLHWeight_swigregister(DLHWeight)
6133
6134class PL2Weight(Weight):
6135    """
6136
6137
6138    This class implements the PL2 weighting scheme.
6139
6140    PL2 is a representative scheme of the Divergence from Randomness
6141    Framework by Gianni Amati.
6142
6143    This weighting scheme is useful for tasks that require early
6144    precision.
6145
6146    It uses the Poisson approximation of the Binomial Probabilistic
6147    distribution (P) along with Stirling's approximation for the factorial
6148    value, the Laplace method to find the aftereffect of sampling (L) and
6149    the second wdf normalization proposed by Amati to normalize the wdf in
6150    the document to the length of the document (H2).
6151
6152    For more information about the DFR Framework and the PL2 scheme,
6153    please refer to : Gianni Amati and Cornelis Joost Van Rijsbergen
6154    Probabilistic models of information retrieval based on measuring the
6155    divergence from randomness ACM Transactions on Information Systems
6156    (TOIS) 20, (4), 2002, pp. 357-389.
6157    """
6158
6159    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
6160    __repr__ = _swig_repr
6161
6162    def __init__(self, *args):
6163        """Xapian::PL2Weight::PL2Weight() """
6164        _xapian.PL2Weight_swiginit(self, _xapian.new_PL2Weight(*args))
6165    __swig_destroy__ = _xapian.delete_PL2Weight
6166PL2Weight_swigregister = _xapian.PL2Weight_swigregister
6167PL2Weight_swigregister(PL2Weight)
6168
6169class PL2PlusWeight(Weight):
6170    """
6171
6172
6173    Xapian::Weight subclass implementing the PL2+ probabilistic formula.
6174
6175    """
6176
6177    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
6178    __repr__ = _swig_repr
6179
6180    def __init__(self, *args):
6181        """Xapian::PL2PlusWeight::PL2PlusWeight() """
6182        _xapian.PL2PlusWeight_swiginit(self, _xapian.new_PL2PlusWeight(*args))
6183    __swig_destroy__ = _xapian.delete_PL2PlusWeight
6184PL2PlusWeight_swigregister = _xapian.PL2PlusWeight_swigregister
6185PL2PlusWeight_swigregister(PL2PlusWeight)
6186
6187class DPHWeight(Weight):
6188    """
6189
6190
6191    This class implements the DPH weighting scheme.
6192
6193    DPH is a representative scheme of the Divergence from Randomness
6194    Framework by Gianni Amati.
6195
6196    This is a parameter free weighting scheme and it should be used with
6197    query expansion to obtain better results. It uses the HyperGeometric
6198    Probabilistic model and Popper's normalization to calculate the risk
6199    gain.
6200
6201    For more information about the DFR Framework and the DPH scheme,
6202    please refer to : a.) Gianni Amati and Cornelis Joost Van Rijsbergen
6203    Probabilistic models of information retrieval based on measuring the
6204    divergence from randomness ACM Transactions on Information Systems
6205    (TOIS) 20, (4), 2002, pp. 357-389. b.) FUB, IASI-CNR and University of
6206    Tor Vergata at TREC 2007 Blog Track. G. Amati and E. Ambrosi and M.
6207    Bianchi and C. Gaibisso and G. Gambosi. Proceedings of the 16th Text
6208    Retrieval Conference (TREC-2007), 2008.
6209    """
6210
6211    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
6212    __repr__ = _swig_repr
6213
6214    def __init__(self):
6215        """
6216
6217
6218        Construct a DPHWeight.
6219
6220        Xapian::DPHWeight::DPHWeight()
6221        """
6222        _xapian.DPHWeight_swiginit(self, _xapian.new_DPHWeight())
6223    __swig_destroy__ = _xapian.delete_DPHWeight
6224DPHWeight_swigregister = _xapian.DPHWeight_swigregister
6225DPHWeight_swigregister(DPHWeight)
6226
6227class LMWeight(Weight):
6228    """
6229
6230
6231    Xapian::Weight subclass implementing the Language Model formula.
6232
6233    This class implements the "Language Model" Weighting scheme, as
6234    described by the early papers on LM by Bruce Croft.
6235
6236    LM works by comparing the query to a Language Model of the document.
6237    The language model itself is parameter-free, though LMWeight takes
6238    parameters which specify the smoothing used.
6239    """
6240
6241    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
6242    __repr__ = _swig_repr
6243
6244    def __init__(self, *args):
6245        """
6246
6247
6248        Construct a LMWeight.
6249
6250        Xapian::LMWeight::LMWeight(double param_log_=0.0, type_smoothing
6251        select_smoothing_=TWO_STAGE_SMOOTHING, double param_smoothing1_=-1.0,
6252        double param_smoothing2_=-1.0)
6253
6254        Parameters:
6255        -----------
6256
6257        param_log_:  A non-negative parameter controlling how much to clamp
6258        negative values returned by the log. The log is calculated by
6259        multiplying the actual weight by param_log. If param_log is 0.0, then
6260        the document length upper bound will be used (default: document length
6261        upper bound)
6262
6263        select_smoothing_:  A parameter of type enum type_smoothing. This
6264        parameter controls which smoothing type to use. (default:
6265        TWO_STAGE_SMOOTHING)
6266
6267        param_smoothing1_:  A non-negative parameter for smoothing whose
6268        meaning depends on select_smoothing_. In JELINEK_MERCER_SMOOTHING, it
6269        plays the role of estimation and in DIRICHLET_SMOOTHING the role of
6270        query modelling. (default JELINEK_MERCER, ABSOLUTE, TWOSTAGE(0.7),
6271        DIRCHLET(2000))
6272
6273        param_smoothing2_:  A non-negative parameter which is used with
6274        TWO_STAGE_SMOOTHING as parameter for Dirichlet's smoothing (default:
6275        2000) and as parameter delta to control the scale of the tf lower
6276        bound in the DIRICHLET_PLUS_SMOOTHING (default 0.05).
6277        """
6278        _xapian.LMWeight_swiginit(self, _xapian.new_LMWeight(*args))
6279    __swig_destroy__ = _xapian.delete_LMWeight
6280LMWeight_swigregister = _xapian.LMWeight_swigregister
6281LMWeight_swigregister(LMWeight)
6282
6283class CoordWeight(Weight):
6284    """
6285
6286
6287    Xapian::Weight subclass implementing Coordinate Matching.
6288
6289    Each matching term score one point. See Managing Gigabytes, Second
6290    Edition p181.
6291    """
6292
6293    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
6294    __repr__ = _swig_repr
6295
6296    def init(self, factor_):
6297        """
6298
6299
6300        Allow the subclass to perform any initialisation it needs to.
6301
6302        void Xapian::CoordWeight::init(double factor_)
6303
6304        Parameters:
6305        -----------
6306
6307        factor:  Any scaling factor (e.g. from OP_SCALE_WEIGHT). If the Weight
6308        object is for the term-independent weight supplied by
6309        get_sumextra()/get_maxextra(), then init(0.0) is called (starting from
6310        Xapian 1.2.11 and 1.3.1 - earlier versions failed to call init() for
6311        such Weight objects).
6312        """
6313        return _xapian.CoordWeight_init(self, factor_)
6314
6315
6316    def __init__(self):
6317        """
6318
6319
6320        Construct a CoordWeight.
6321
6322        Xapian::CoordWeight::CoordWeight()
6323        """
6324        _xapian.CoordWeight_swiginit(self, _xapian.new_CoordWeight())
6325    __swig_destroy__ = _xapian.delete_CoordWeight
6326CoordWeight.init = _xapian.SWIG_PyInstanceMethod_New(_xapian.CoordWeight_init)
6327CoordWeight_swigregister = _xapian.CoordWeight_swigregister
6328CoordWeight_swigregister(CoordWeight)
6329
6330class Compactor(object):
6331    """
6332
6333
6334    Compact a database, or merge and compact several.
6335    """
6336
6337    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
6338    __repr__ = _swig_repr
6339    STANDARD = _xapian.Compactor_STANDARD
6340    FULL = _xapian.Compactor_FULL
6341    FULLER = _xapian.Compactor_FULLER
6342
6343    def __init__(self):
6344        """Xapian::Compactor::Compactor() """
6345        if self.__class__ == Compactor:
6346            _self = None
6347        else:
6348            _self = self
6349        _xapian.Compactor_swiginit(self, _xapian.new_Compactor(_self, ))
6350    __swig_destroy__ = _xapian.delete_Compactor
6351
6352    def set_block_size(self, block_size):
6353        """
6354
6355
6356        Set the block size to use for tables in the output database.
6357
6358        void Xapian::Compactor::set_block_size(size_t block_size)
6359
6360        Parameters:
6361        -----------
6362
6363        block_size:  The block size to use. Valid block sizes are currently
6364        powers of two between 2048 and 65536, with the default being 8192, but
6365        the valid sizes and default may change in the future.
6366        """
6367        return _xapian.Compactor_set_block_size(self, block_size)
6368
6369
6370    def set_renumber(self, renumber):
6371        """
6372
6373
6374        Set whether to preserve existing document id values.
6375
6376        void Xapian::Compactor::set_renumber(bool renumber)
6377
6378        Parameters:
6379        -----------
6380
6381        renumber:  The default is true, which means that document ids will be
6382        renumbered - currently by applying the same offset to all the document
6383        ids in a particular source database.
6384
6385        If false, then the document ids must be unique over all source
6386        databases. Currently the ranges of document ids in each source must
6387        not overlap either, though this restriction may be removed in the
6388        future.
6389        """
6390        return _xapian.Compactor_set_renumber(self, renumber)
6391
6392
6393    def set_multipass(self, multipass):
6394        """
6395
6396
6397        Set whether to merge postlists in multiple passes.
6398
6399        void Xapian::Compactor::set_multipass(bool multipass)
6400
6401        Parameters:
6402        -----------
6403
6404        multipass:  If true and merging more than 3 databases, merge the
6405        postlists in multiple passes, which is generally faster but requires
6406        more disk space for temporary files. By default we don't do this.
6407        """
6408        return _xapian.Compactor_set_multipass(self, multipass)
6409
6410
6411    def set_compaction_level(self, compaction):
6412        """
6413
6414
6415        Set the compaction level.
6416
6417        void Xapian::Compactor::set_compaction_level(compaction_level
6418        compaction)
6419
6420        Parameters:
6421        -----------
6422
6423        compaction:  Available values are:  Xapian::Compactor::STANDARD -
6424        Don't split items unnecessarily.
6425
6426        Xapian::Compactor::FULL - Split items whenever it saves space (the
6427        default).
6428
6429        Xapian::Compactor::FULLER - Allow oversize items to save more space
6430        (not recommended if you ever plan to update the compacted database).
6431
6432        """
6433        return _xapian.Compactor_set_compaction_level(self, compaction)
6434
6435
6436    def set_destdir(self, destdir):
6437        """
6438
6439
6440        Set where to write the output.
6441
6442        void Xapian::Compactor::set_destdir(const std::string &destdir)
6443
6444        Deprecated Use Database::compact(destdir[, compactor]) instead.
6445
6446        Parameters:
6447        -----------
6448
6449        destdir:  Output path. This can be the same as an input if that input
6450        is a stub database (in which case the database(s) listed in the stub
6451        will be compacted to a new database and then the stub will be
6452        atomically updated to point to this new database).
6453        """
6454        return _xapian.Compactor_set_destdir(self, destdir)
6455
6456
6457    def add_source(self, srcdir):
6458        """
6459
6460
6461        Add a source database.
6462
6463        void Xapian::Compactor::add_source(const std::string &srcdir)
6464
6465        Deprecated Use Database::compact(destdir[, compactor]) instead.
6466
6467        Parameters:
6468        -----------
6469
6470        srcdir:  The path to the source database to add.
6471        """
6472        return _xapian.Compactor_add_source(self, srcdir)
6473
6474
6475    def compact(self):
6476        """
6477
6478
6479        Perform the actual compaction/merging operation.
6480
6481        void Xapian::Compactor::compact()
6482
6483        Deprecated Use Database::compact(destdir[, compactor]) instead.
6484        """
6485        return _xapian.Compactor_compact(self)
6486
6487
6488    def set_status(self, table, status):
6489        """
6490
6491
6492        Update progress.
6493
6494        virtual void Xapian::Compactor::set_status(const std::string &table,
6495        const std::string &status)
6496
6497        Subclass this method if you want to get progress updates during
6498        compaction. This is called for each table first with empty status, And
6499        then one or more times with non-empty status.
6500
6501        The default implementation does nothing.
6502
6503        Parameters:
6504        -----------
6505
6506        table:  The table currently being compacted.
6507
6508        status:  A status message.
6509        """
6510        return _xapian.Compactor_set_status(self, table, status)
6511
6512
6513    def resolve_duplicate_metadata(self, key, num_tags, tags):
6514        """
6515
6516
6517        Resolve multiple user metadata entries with the same key.
6518
6519        virtual std::string
6520        Xapian::Compactor::resolve_duplicate_metadata(const std::string &key,
6521        size_t num_tags, const std::string tags[])
6522
6523        When merging, if the same user metadata key is set in more than one
6524        input, then this method is called to allow this to be resolving in an
6525        appropriate way.
6526
6527        The default implementation just returns tags[0].
6528
6529        For multipass this will currently get called multiple times for the
6530        same key if there are duplicates to resolve in each pass, but this may
6531        change in the future.
6532
6533        Since 1.4.6, an implementation of this method can return an empty
6534        string to indicate that the appropriate result is to not set a value
6535        for this user metadata key in the output database. In older versions,
6536        you should not return an empty string.
6537
6538        Parameters:
6539        -----------
6540
6541        key:  The metadata key with duplicate entries.
6542
6543        num_tags:  How many tags there are.
6544
6545        tags:  An array of num_tags strings containing the tags to merge.
6546        """
6547        return _xapian.Compactor_resolve_duplicate_metadata(self, key, num_tags, tags)
6548
6549    def __disown__(self):
6550        self.this.disown()
6551        _xapian.disown_Compactor(self)
6552        return weakref_proxy(self)
6553Compactor.set_block_size = _xapian.SWIG_PyInstanceMethod_New(_xapian.Compactor_set_block_size)
6554Compactor.set_renumber = _xapian.SWIG_PyInstanceMethod_New(_xapian.Compactor_set_renumber)
6555Compactor.set_multipass = _xapian.SWIG_PyInstanceMethod_New(_xapian.Compactor_set_multipass)
6556Compactor.set_compaction_level = _xapian.SWIG_PyInstanceMethod_New(_xapian.Compactor_set_compaction_level)
6557Compactor.set_destdir = _xapian.SWIG_PyInstanceMethod_New(_xapian.Compactor_set_destdir)
6558Compactor.add_source = _xapian.SWIG_PyInstanceMethod_New(_xapian.Compactor_add_source)
6559Compactor.compact = _xapian.SWIG_PyInstanceMethod_New(_xapian.Compactor_compact)
6560Compactor.set_status = _xapian.SWIG_PyInstanceMethod_New(_xapian.Compactor_set_status)
6561Compactor.resolve_duplicate_metadata = _xapian.SWIG_PyInstanceMethod_New(_xapian.Compactor_resolve_duplicate_metadata)
6562Compactor_swigregister = _xapian.Compactor_swigregister
6563Compactor_swigregister(Compactor)
6564
6565class PostingSource(object):
6566    """
6567
6568
6569    Base class which provides an "external" source of postings.
6570    """
6571
6572    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
6573    __repr__ = _swig_repr
6574
6575    def __init__(self):
6576        """
6577
6578
6579        Allow subclasses to be instantiated.
6580
6581        Xapian::PostingSource::PostingSource()
6582        """
6583        if self.__class__ == PostingSource:
6584            _self = None
6585        else:
6586            _self = self
6587        _xapian.PostingSource_swiginit(self, _xapian.new_PostingSource(_self, ))
6588    __swig_destroy__ = _xapian.delete_PostingSource
6589
6590    def get_termfreq_min(self):
6591        """
6592
6593
6594        A lower bound on the number of documents this object can return.
6595
6596        virtual Xapian::doccount Xapian::PostingSource::get_termfreq_min()
6597        const =0
6598
6599        Xapian will always call init() on a PostingSource before calling this
6600        for the first time.
6601        """
6602        return _xapian.PostingSource_get_termfreq_min(self)
6603
6604
6605    def get_termfreq_est(self):
6606        """
6607
6608
6609        An estimate of the number of documents this object can return.
6610
6611        virtual Xapian::doccount Xapian::PostingSource::get_termfreq_est()
6612        const =0
6613
6614        It must always be true that:
6615
6616        get_termfreq_min() <= get_termfreq_est() <= get_termfreq_max()
6617
6618        Xapian will always call init() on a PostingSource before calling this
6619        for the first time.
6620        """
6621        return _xapian.PostingSource_get_termfreq_est(self)
6622
6623
6624    def get_termfreq_max(self):
6625        """
6626
6627
6628        An upper bound on the number of documents this object can return.
6629
6630        virtual Xapian::doccount Xapian::PostingSource::get_termfreq_max()
6631        const =0
6632
6633        Xapian will always call init() on a PostingSource before calling this
6634        for the first time.
6635        """
6636        return _xapian.PostingSource_get_termfreq_max(self)
6637
6638
6639    def set_maxweight(self, max_weight):
6640        """
6641
6642
6643        Specify an upper bound on what get_weight() will return from now on.
6644
6645        void Xapian::PostingSource::set_maxweight(double max_weight)
6646
6647        This upper bound is used by the matcher to perform various
6648        optimisations, so if you can return a good bound, then matches will
6649        generally run faster.
6650
6651        This method should be called after calling init(), and may be called
6652        during iteration if the upper bound drops. It is probably only useful
6653        to call from subclasses (it was actually a "protected" method prior
6654        to Xapian 1.3.4, but that makes it tricky to wrap for other
6655        languages).
6656
6657        It is valid for the posting source to have returned a higher value
6658        from get_weight() earlier in the iteration, but the posting source
6659        must not return a higher value from get_weight() than the currently
6660        set upper bound, and the upper bound must not be increased (until
6661        init() has been called).
6662
6663        If you don't call this method, the upper bound will default to 0, for
6664        convenience when implementing "weight-less" PostingSource
6665        subclasses.
6666
6667        Parameters:
6668        -----------
6669
6670        max_weight:  The upper bound to set.
6671        """
6672        return _xapian.PostingSource_set_maxweight(self, max_weight)
6673
6674
6675    def get_maxweight(self):
6676        """
6677
6678
6679        Return the currently set upper bound on what get_weight() can return.
6680
6681        double Xapian::PostingSource::get_maxweight() const
6682        """
6683        return _xapian.PostingSource_get_maxweight(self)
6684
6685
6686    def get_weight(self):
6687        """
6688
6689
6690        Return the weight contribution for the current document.
6691
6692        virtual double Xapian::PostingSource::get_weight() const
6693
6694        This default implementation always returns 0, for convenience when
6695        implementing "weight-less" PostingSource subclasses.
6696
6697        This method may assume that it will only be called when there is a
6698        "current document". In detail: Xapian will always call init() on a
6699        PostingSource before calling this for the first time. It will also
6700        only call this if the PostingSource reports that it is pointing to a
6701        valid document (ie, it will not call it before calling at least one of
6702        next(), skip_to() or check(), and will ensure that the PostingSource
6703        is not at the end by calling at_end()).
6704        """
6705        return _xapian.PostingSource_get_weight(self)
6706
6707
6708    def get_docid(self):
6709        """
6710
6711
6712        Return the current docid.
6713
6714        virtual Xapian::docid Xapian::PostingSource::get_docid() const =0
6715
6716        This method may assume that it will only be called when there is a
6717        "current document". See  get_weight() for details.
6718
6719        Note: in the case of a multi-database search, the returned docid
6720        should be in the single subdatabase relevant to this posting source.
6721        See the  init() method for details.
6722        """
6723        return _xapian.PostingSource_get_docid(self)
6724
6725
6726    def __next__(self, min_wt):
6727        """
6728
6729
6730        Advance the current position to the next matching document.
6731
6732        virtual void Xapian::PostingSource::next(double min_wt)=0
6733
6734        The PostingSource starts before the first entry in the list, so
6735        next(), skip_to() or check() must be called before any methods which
6736        need the context of the current position.
6737
6738        Xapian will always call init() on a PostingSource before calling this
6739        for the first time.
6740
6741        Parameters:
6742        -----------
6743
6744        min_wt:  The minimum weight contribution that is needed (this is just
6745        a hint which subclasses may ignore).
6746        """
6747        return _xapian.PostingSource___next__(self, min_wt)
6748
6749
6750    def skip_to(self, did, min_wt):
6751        """
6752
6753
6754        Advance to the specified docid.
6755
6756        virtual void Xapian::PostingSource::skip_to(Xapian::docid did, double
6757        min_wt)
6758
6759        If the specified docid isn't in the list, position ourselves on the
6760        first document after it (or at_end() if no greater docids are
6761        present).
6762
6763        If the current position is already the specified docid, this method
6764        will leave the position unmodified.
6765
6766        If the specified docid is earlier than the current position, the
6767        behaviour is unspecified. A sensible behaviour would be to leave the
6768        current position unmodified, but it is also reasonable to move to the
6769        specified docid.
6770
6771        The default implementation calls next() repeatedly, which works but
6772        skip_to() can often be implemented much more efficiently.
6773
6774        Xapian will always call init() on a PostingSource before calling this
6775        for the first time.
6776
6777        Note: in the case of a multi-database search, the docid specified is
6778        the docid in the single subdatabase relevant to this posting source.
6779        See the  init() method for details.
6780
6781        Parameters:
6782        -----------
6783
6784        did:  The document id to advance to.
6785
6786        min_wt:  The minimum weight contribution that is needed (this is just
6787        a hint which subclasses may ignore).
6788        """
6789        return _xapian.PostingSource_skip_to(self, did, min_wt)
6790
6791
6792    def check(self, did, min_wt):
6793        """
6794
6795
6796        Check if the specified docid occurs.
6797
6798        virtual bool Xapian::PostingSource::check(Xapian::docid did, double
6799        min_wt)
6800
6801        The caller is required to ensure that the specified document id did
6802        actually exists in the database. If it does, it must move to that
6803        document id, and return true. If it does not, it may either:
6804
6805        return true, having moved to a definite position (including
6806        "at_end"), which must be the same position as skip_to() would have
6807        moved to.
6808
6809        or
6810
6811        return false, having moved to an "indeterminate" position, such that
6812        a subsequent call to next() or skip_to() will move to the next
6813        matching position after did.
6814
6815        Generally, this method should act like skip_to() and return true if
6816        that can be done at little extra cost.
6817
6818        Otherwise it should simply check if a particular docid is present,
6819        returning true if it is, and false if it isn't.
6820
6821        The default implementation calls skip_to() and always returns true.
6822
6823        Xapian will always call init() on a PostingSource before calling this
6824        for the first time.
6825
6826        Note: in the case of a multi-database search, the docid specified is
6827        the docid in the single subdatabase relevant to this posting source.
6828        See the  init() method for details.
6829
6830        Parameters:
6831        -----------
6832
6833        did:  The document id to check.
6834
6835        min_wt:  The minimum weight contribution that is needed (this is just
6836        a hint which subclasses may ignore).
6837        """
6838        return _xapian.PostingSource_check(self, did, min_wt)
6839
6840
6841    def at_end(self):
6842        """
6843
6844
6845        Return true if the current position is past the last entry in this
6846        list.
6847
6848        virtual bool Xapian::PostingSource::at_end() const =0
6849
6850        At least one of  next(),  skip_to() or  check() will be called before
6851        this method is first called.
6852        """
6853        return _xapian.PostingSource_at_end(self)
6854
6855
6856    def name(self):
6857        """
6858
6859
6860        Name of the posting source class.
6861
6862        virtual std::string Xapian::PostingSource::name() const
6863
6864        This is used when serialising and unserialising posting sources; for
6865        example, for performing remote searches.
6866
6867        If the subclass is in a C++ namespace, the namespace should be
6868        included in the name, using "::" as a separator. For example, for a
6869        PostingSource subclass called "FooPostingSource" in the "Xapian"
6870        namespace the result of this call should be
6871        "Xapian::FooPostingSource".
6872
6873        This should only be implemented if serialise() and unserialise() are
6874        also implemented. The default implementation returns an empty string.
6875
6876        If this returns an empty string, Xapian will assume that serialise()
6877        and unserialise() are not implemented.
6878        """
6879        return _xapian.PostingSource_name(self)
6880
6881
6882    def init(self, db):
6883        """
6884
6885
6886        Set this PostingSource to the start of the list of postings.
6887
6888        virtual void Xapian::PostingSource::init(const Database &db)=0
6889
6890        This is called automatically by the matcher prior to each query being
6891        processed.
6892
6893        If a PostingSource is used for multiple searches,  init() will
6894        therefore be called multiple times, and must handle this by using the
6895        database passed in the most recent call.
6896
6897        Parameters:
6898        -----------
6899
6900        db:  The database which the PostingSource should iterate through.
6901
6902        Note: in the case of a multi-database search, a separate PostingSource
6903        will be used for each database (the separate PostingSources will be
6904        obtained using  clone()), and each PostingSource will be passed one of
6905        the sub-databases as the db parameter here. The db parameter will
6906        therefore always refer to a single database. All docids passed to, or
6907        returned from, the PostingSource refer to docids in that single
6908        database, rather than in the multi- database.
6909        """
6910        return _xapian.PostingSource_init(self, db)
6911
6912
6913    def __str__(self):
6914        """
6915
6916
6917        Return a string describing this object.
6918
6919        virtual std::string Xapian::PostingSource::get_description() const
6920
6921        This default implementation returns a generic answer. This default it
6922        provided to avoid forcing those deriving their own PostingSource
6923        subclass from having to implement this (they may not care what
6924        get_description() gives for their subclass).
6925        """
6926        return _xapian.PostingSource___str__(self)
6927
6928
6929    def release(self):
6930        """
6931
6932
6933        Start reference counting this object.
6934
6935        const PostingSource* Xapian::PostingSource::release() const
6936
6937        You can hand ownership of a dynamically allocated PostingSource object
6938        to Xapian by calling release() and then passing the object to a Xapian
6939        method. Xapian will arrange to delete the object once it is no longer
6940        required.
6941        """
6942        return _xapian.PostingSource_release(self)
6943
6944    def __disown__(self):
6945        self.this.disown()
6946        _xapian.disown_PostingSource(self)
6947        return weakref_proxy(self)
6948PostingSource.get_termfreq_min = _xapian.SWIG_PyInstanceMethod_New(_xapian.PostingSource_get_termfreq_min)
6949PostingSource.get_termfreq_est = _xapian.SWIG_PyInstanceMethod_New(_xapian.PostingSource_get_termfreq_est)
6950PostingSource.get_termfreq_max = _xapian.SWIG_PyInstanceMethod_New(_xapian.PostingSource_get_termfreq_max)
6951PostingSource.set_maxweight = _xapian.SWIG_PyInstanceMethod_New(_xapian.PostingSource_set_maxweight)
6952PostingSource.get_maxweight = _xapian.SWIG_PyInstanceMethod_New(_xapian.PostingSource_get_maxweight)
6953PostingSource.get_weight = _xapian.SWIG_PyInstanceMethod_New(_xapian.PostingSource_get_weight)
6954PostingSource.get_docid = _xapian.SWIG_PyInstanceMethod_New(_xapian.PostingSource_get_docid)
6955PostingSource.__next__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.PostingSource___next__)
6956PostingSource.skip_to = _xapian.SWIG_PyInstanceMethod_New(_xapian.PostingSource_skip_to)
6957PostingSource.check = _xapian.SWIG_PyInstanceMethod_New(_xapian.PostingSource_check)
6958PostingSource.at_end = _xapian.SWIG_PyInstanceMethod_New(_xapian.PostingSource_at_end)
6959PostingSource.name = _xapian.SWIG_PyInstanceMethod_New(_xapian.PostingSource_name)
6960PostingSource.init = _xapian.SWIG_PyInstanceMethod_New(_xapian.PostingSource_init)
6961PostingSource.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.PostingSource___str__)
6962PostingSource.release = _xapian.SWIG_PyInstanceMethod_New(_xapian.PostingSource_release)
6963PostingSource_swigregister = _xapian.PostingSource_swigregister
6964PostingSource_swigregister(PostingSource)
6965
6966class ValuePostingSource(PostingSource):
6967    """
6968
6969
6970    A posting source which generates weights from a value slot.
6971
6972    This is a base class for classes which generate weights using values
6973    stored in the specified slot. For example, ValueWeightPostingSource
6974    uses sortable_unserialise to convert values directly to weights.
6975
6976    The upper bound on the weight returned is set to DBL_MAX. Subclasses
6977    should call set_maxweight() in their init() methods after calling
6978    ValuePostingSource::init() if they know a tighter bound on the weight.
6979
6980    """
6981
6982    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
6983    __repr__ = _swig_repr
6984
6985    def __init__(self, slot_):
6986        """
6987
6988
6989        Construct a ValuePostingSource.
6990
6991        Xapian::ValuePostingSource::ValuePostingSource(Xapian::valueno slot_)
6992
6993        Parameters:
6994        -----------
6995
6996        slot_:  The value slot to read values from.
6997        """
6998        if self.__class__ == ValuePostingSource:
6999            _self = None
7000        else:
7001            _self = self
7002        _xapian.ValuePostingSource_swiginit(self, _xapian.new_ValuePostingSource(_self, slot_))
7003
7004    def get_termfreq_min(self):
7005        """
7006
7007
7008        A lower bound on the number of documents this object can return.
7009
7010        Xapian::doccount Xapian::ValuePostingSource::get_termfreq_min() const
7011
7012        Xapian will always call init() on a PostingSource before calling this
7013        for the first time.
7014        """
7015        return _xapian.ValuePostingSource_get_termfreq_min(self)
7016
7017
7018    def get_termfreq_est(self):
7019        """
7020
7021
7022        An estimate of the number of documents this object can return.
7023
7024        Xapian::doccount Xapian::ValuePostingSource::get_termfreq_est() const
7025
7026        It must always be true that:
7027
7028        get_termfreq_min() <= get_termfreq_est() <= get_termfreq_max()
7029
7030        Xapian will always call init() on a PostingSource before calling this
7031        for the first time.
7032        """
7033        return _xapian.ValuePostingSource_get_termfreq_est(self)
7034
7035
7036    def get_termfreq_max(self):
7037        """
7038
7039
7040        An upper bound on the number of documents this object can return.
7041
7042        Xapian::doccount Xapian::ValuePostingSource::get_termfreq_max() const
7043
7044        Xapian will always call init() on a PostingSource before calling this
7045        for the first time.
7046        """
7047        return _xapian.ValuePostingSource_get_termfreq_max(self)
7048
7049
7050    def __next__(self, min_wt):
7051        """
7052
7053
7054        Advance the current position to the next matching document.
7055
7056        void Xapian::ValuePostingSource::next(double min_wt)
7057
7058        The PostingSource starts before the first entry in the list, so
7059        next(), skip_to() or check() must be called before any methods which
7060        need the context of the current position.
7061
7062        Xapian will always call init() on a PostingSource before calling this
7063        for the first time.
7064
7065        Parameters:
7066        -----------
7067
7068        min_wt:  The minimum weight contribution that is needed (this is just
7069        a hint which subclasses may ignore).
7070        """
7071        return _xapian.ValuePostingSource___next__(self, min_wt)
7072
7073
7074    def skip_to(self, min_docid, min_wt):
7075        """
7076
7077
7078        Advance to the specified docid.
7079
7080        void Xapian::ValuePostingSource::skip_to(Xapian::docid min_docid,
7081        double min_wt)
7082
7083        If the specified docid isn't in the list, position ourselves on the
7084        first document after it (or at_end() if no greater docids are
7085        present).
7086
7087        If the current position is already the specified docid, this method
7088        will leave the position unmodified.
7089
7090        If the specified docid is earlier than the current position, the
7091        behaviour is unspecified. A sensible behaviour would be to leave the
7092        current position unmodified, but it is also reasonable to move to the
7093        specified docid.
7094
7095        The default implementation calls next() repeatedly, which works but
7096        skip_to() can often be implemented much more efficiently.
7097
7098        Xapian will always call init() on a PostingSource before calling this
7099        for the first time.
7100
7101        Note: in the case of a multi-database search, the docid specified is
7102        the docid in the single subdatabase relevant to this posting source.
7103        See the  init() method for details.
7104
7105        Parameters:
7106        -----------
7107
7108        did:  The document id to advance to.
7109
7110        min_wt:  The minimum weight contribution that is needed (this is just
7111        a hint which subclasses may ignore).
7112        """
7113        return _xapian.ValuePostingSource_skip_to(self, min_docid, min_wt)
7114
7115
7116    def check(self, min_docid, min_wt):
7117        """
7118
7119
7120        Check if the specified docid occurs.
7121
7122        bool Xapian::ValuePostingSource::check(Xapian::docid min_docid, double
7123        min_wt)
7124
7125        The caller is required to ensure that the specified document id did
7126        actually exists in the database. If it does, it must move to that
7127        document id, and return true. If it does not, it may either:
7128
7129        return true, having moved to a definite position (including
7130        "at_end"), which must be the same position as skip_to() would have
7131        moved to.
7132
7133        or
7134
7135        return false, having moved to an "indeterminate" position, such that
7136        a subsequent call to next() or skip_to() will move to the next
7137        matching position after did.
7138
7139        Generally, this method should act like skip_to() and return true if
7140        that can be done at little extra cost.
7141
7142        Otherwise it should simply check if a particular docid is present,
7143        returning true if it is, and false if it isn't.
7144
7145        The default implementation calls skip_to() and always returns true.
7146
7147        Xapian will always call init() on a PostingSource before calling this
7148        for the first time.
7149
7150        Note: in the case of a multi-database search, the docid specified is
7151        the docid in the single subdatabase relevant to this posting source.
7152        See the  init() method for details.
7153
7154        Parameters:
7155        -----------
7156
7157        did:  The document id to check.
7158
7159        min_wt:  The minimum weight contribution that is needed (this is just
7160        a hint which subclasses may ignore).
7161        """
7162        return _xapian.ValuePostingSource_check(self, min_docid, min_wt)
7163
7164
7165    def at_end(self):
7166        """
7167
7168
7169        Return true if the current position is past the last entry in this
7170        list.
7171
7172        bool Xapian::ValuePostingSource::at_end() const
7173
7174        At least one of  next(),  skip_to() or  check() will be called before
7175        this method is first called.
7176        """
7177        return _xapian.ValuePostingSource_at_end(self)
7178
7179
7180    def get_docid(self):
7181        """
7182
7183
7184        Return the current docid.
7185
7186        Xapian::docid Xapian::ValuePostingSource::get_docid() const
7187
7188        This method may assume that it will only be called when there is a
7189        "current document". See  get_weight() for details.
7190
7191        Note: in the case of a multi-database search, the returned docid
7192        should be in the single subdatabase relevant to this posting source.
7193        See the  init() method for details.
7194        """
7195        return _xapian.ValuePostingSource_get_docid(self)
7196
7197
7198    def init(self, db_):
7199        """
7200
7201
7202        Set this PostingSource to the start of the list of postings.
7203
7204        void Xapian::ValuePostingSource::init(const Database &db_)
7205
7206        This is called automatically by the matcher prior to each query being
7207        processed.
7208
7209        If a PostingSource is used for multiple searches,  init() will
7210        therefore be called multiple times, and must handle this by using the
7211        database passed in the most recent call.
7212
7213        Parameters:
7214        -----------
7215
7216        db:  The database which the PostingSource should iterate through.
7217
7218        Note: in the case of a multi-database search, a separate PostingSource
7219        will be used for each database (the separate PostingSources will be
7220        obtained using  clone()), and each PostingSource will be passed one of
7221        the sub-databases as the db parameter here. The db parameter will
7222        therefore always refer to a single database. All docids passed to, or
7223        returned from, the PostingSource refer to docids in that single
7224        database, rather than in the multi- database.
7225        """
7226        return _xapian.ValuePostingSource_init(self, db_)
7227
7228
7229    def get_database(self):
7230        """
7231
7232
7233        The database we're reading values from.
7234
7235        Xapian::Database Xapian::ValuePostingSource::get_database() const
7236
7237        Added in 1.2.23 and 1.3.5.
7238        """
7239        return _xapian.ValuePostingSource_get_database(self)
7240
7241
7242    def get_slot(self):
7243        """
7244
7245
7246        The slot we're reading values from.
7247
7248        Xapian::valueno Xapian::ValuePostingSource::get_slot() const
7249
7250        Added in 1.2.23 and 1.3.5.
7251        """
7252        return _xapian.ValuePostingSource_get_slot(self)
7253
7254
7255    def get_value(self):
7256        """
7257
7258
7259        Read current value.
7260
7261        std::string Xapian::ValuePostingSource::get_value() const
7262
7263        Added in 1.2.23 and 1.3.5.
7264        """
7265        return _xapian.ValuePostingSource_get_value(self)
7266
7267
7268    def done(self):
7269        """
7270
7271
7272        End the iteration.
7273
7274        void Xapian::ValuePostingSource::done()
7275
7276        Calls to at_end() will return true after calling this method.
7277
7278        Added in 1.2.23 and 1.3.5.
7279        """
7280        return _xapian.ValuePostingSource_done(self)
7281
7282
7283    def get_started(self):
7284        """
7285
7286
7287        Flag indicating if we've started (true if we have).
7288
7289        bool Xapian::ValuePostingSource::get_started() const
7290
7291        Added in 1.2.23 and 1.3.5.
7292        """
7293        return _xapian.ValuePostingSource_get_started(self)
7294
7295
7296    def set_termfreq_min(self, termfreq_min_):
7297        """
7298
7299
7300        Set a lower bound on the term frequency.
7301
7302        void Xapian::ValuePostingSource::set_termfreq_min(Xapian::doccount
7303        termfreq_min_)
7304
7305        Subclasses should set this if they are overriding the next(),
7306        skip_to() or check() methods to return fewer documents.
7307
7308        Added in 1.2.23 and 1.3.5.
7309        """
7310        return _xapian.ValuePostingSource_set_termfreq_min(self, termfreq_min_)
7311
7312
7313    def set_termfreq_est(self, termfreq_est_):
7314        """
7315
7316
7317        An estimate of the term frequency.
7318
7319        void Xapian::ValuePostingSource::set_termfreq_est(Xapian::doccount
7320        termfreq_est_)
7321
7322        Subclasses should set this if they are overriding the next(),
7323        skip_to() or check() methods.
7324
7325        Added in 1.2.23 and 1.3.5.
7326        """
7327        return _xapian.ValuePostingSource_set_termfreq_est(self, termfreq_est_)
7328
7329
7330    def set_termfreq_max(self, termfreq_max_):
7331        """
7332
7333
7334        An upper bound on the term frequency.
7335
7336        void Xapian::ValuePostingSource::set_termfreq_max(Xapian::doccount
7337        termfreq_max_)
7338
7339        Subclasses should set this if they are overriding the next(),
7340        skip_to() or check() methods.
7341
7342        Added in 1.2.23 and 1.3.5.
7343        """
7344        return _xapian.ValuePostingSource_set_termfreq_max(self, termfreq_max_)
7345
7346    __swig_destroy__ = _xapian.delete_ValuePostingSource
7347    def __disown__(self):
7348        self.this.disown()
7349        _xapian.disown_ValuePostingSource(self)
7350        return weakref_proxy(self)
7351ValuePostingSource.get_termfreq_min = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValuePostingSource_get_termfreq_min)
7352ValuePostingSource.get_termfreq_est = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValuePostingSource_get_termfreq_est)
7353ValuePostingSource.get_termfreq_max = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValuePostingSource_get_termfreq_max)
7354ValuePostingSource.__next__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValuePostingSource___next__)
7355ValuePostingSource.skip_to = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValuePostingSource_skip_to)
7356ValuePostingSource.check = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValuePostingSource_check)
7357ValuePostingSource.at_end = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValuePostingSource_at_end)
7358ValuePostingSource.get_docid = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValuePostingSource_get_docid)
7359ValuePostingSource.init = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValuePostingSource_init)
7360ValuePostingSource.get_database = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValuePostingSource_get_database)
7361ValuePostingSource.get_slot = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValuePostingSource_get_slot)
7362ValuePostingSource.get_value = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValuePostingSource_get_value)
7363ValuePostingSource.done = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValuePostingSource_done)
7364ValuePostingSource.get_started = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValuePostingSource_get_started)
7365ValuePostingSource.set_termfreq_min = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValuePostingSource_set_termfreq_min)
7366ValuePostingSource.set_termfreq_est = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValuePostingSource_set_termfreq_est)
7367ValuePostingSource.set_termfreq_max = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValuePostingSource_set_termfreq_max)
7368ValuePostingSource_swigregister = _xapian.ValuePostingSource_swigregister
7369ValuePostingSource_swigregister(ValuePostingSource)
7370
7371class ValueWeightPostingSource(ValuePostingSource):
7372    """
7373
7374
7375    A posting source which reads weights from a value slot.
7376
7377    This returns entries for all documents in the given database which
7378    have a non empty values in the specified slot. It returns a weight
7379    calculated by applying sortable_unserialise to the value stored in the
7380    slot (so the values stored should probably have been calculated by
7381    applying sortable_serialise to a floating point number at index time).
7382
7383    The upper bound on the weight returned is set using the upper bound on
7384    the values in the specified slot, or DBL_MAX if value bounds aren't
7385    supported by the current backend.
7386
7387    For efficiency, this posting source doesn't check that the stored
7388    values are valid in any way, so it will never raise an exception due
7389    to invalid stored values. In particular, it doesn't ensure that the
7390    unserialised values are positive, which is a requirement for weights.
7391    The behaviour if the slot contains values which unserialise to
7392    negative values is undefined.
7393    """
7394
7395    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
7396    __repr__ = _swig_repr
7397
7398    def __init__(self, slot_):
7399        """
7400
7401
7402        Construct a ValueWeightPostingSource.
7403
7404        Xapian::ValueWeightPostingSource::ValueWeightPostingSource(Xapian::valueno
7405        slot_)
7406
7407        Parameters:
7408        -----------
7409
7410        slot_:  The value slot to read values from.
7411        """
7412        if self.__class__ == ValueWeightPostingSource:
7413            _self = None
7414        else:
7415            _self = self
7416        _xapian.ValueWeightPostingSource_swiginit(self, _xapian.new_ValueWeightPostingSource(_self, slot_))
7417
7418    def get_weight(self):
7419        """
7420
7421
7422        Return the weight contribution for the current document.
7423
7424        double Xapian::ValueWeightPostingSource::get_weight() const
7425
7426        This default implementation always returns 0, for convenience when
7427        implementing "weight-less" PostingSource subclasses.
7428
7429        This method may assume that it will only be called when there is a
7430        "current document". In detail: Xapian will always call init() on a
7431        PostingSource before calling this for the first time. It will also
7432        only call this if the PostingSource reports that it is pointing to a
7433        valid document (ie, it will not call it before calling at least one of
7434        next(), skip_to() or check(), and will ensure that the PostingSource
7435        is not at the end by calling at_end()).
7436        """
7437        return _xapian.ValueWeightPostingSource_get_weight(self)
7438
7439
7440    def name(self):
7441        """
7442
7443
7444        Name of the posting source class.
7445
7446        std::string Xapian::ValueWeightPostingSource::name() const
7447
7448        This is used when serialising and unserialising posting sources; for
7449        example, for performing remote searches.
7450
7451        If the subclass is in a C++ namespace, the namespace should be
7452        included in the name, using "::" as a separator. For example, for a
7453        PostingSource subclass called "FooPostingSource" in the "Xapian"
7454        namespace the result of this call should be
7455        "Xapian::FooPostingSource".
7456
7457        This should only be implemented if serialise() and unserialise() are
7458        also implemented. The default implementation returns an empty string.
7459
7460        If this returns an empty string, Xapian will assume that serialise()
7461        and unserialise() are not implemented.
7462        """
7463        return _xapian.ValueWeightPostingSource_name(self)
7464
7465
7466    def init(self, db_):
7467        """
7468
7469
7470        Set this PostingSource to the start of the list of postings.
7471
7472        void Xapian::ValueWeightPostingSource::init(const Database &db_)
7473
7474        This is called automatically by the matcher prior to each query being
7475        processed.
7476
7477        If a PostingSource is used for multiple searches,  init() will
7478        therefore be called multiple times, and must handle this by using the
7479        database passed in the most recent call.
7480
7481        Parameters:
7482        -----------
7483
7484        db:  The database which the PostingSource should iterate through.
7485
7486        Note: in the case of a multi-database search, a separate PostingSource
7487        will be used for each database (the separate PostingSources will be
7488        obtained using  clone()), and each PostingSource will be passed one of
7489        the sub-databases as the db parameter here. The db parameter will
7490        therefore always refer to a single database. All docids passed to, or
7491        returned from, the PostingSource refer to docids in that single
7492        database, rather than in the multi- database.
7493        """
7494        return _xapian.ValueWeightPostingSource_init(self, db_)
7495
7496
7497    def __str__(self):
7498        """
7499
7500
7501        Return a string describing this object.
7502
7503        std::string Xapian::ValueWeightPostingSource::get_description() const
7504
7505        This default implementation returns a generic answer. This default it
7506        provided to avoid forcing those deriving their own PostingSource
7507        subclass from having to implement this (they may not care what
7508        get_description() gives for their subclass).
7509        """
7510        return _xapian.ValueWeightPostingSource___str__(self)
7511
7512    __swig_destroy__ = _xapian.delete_ValueWeightPostingSource
7513    def __disown__(self):
7514        self.this.disown()
7515        _xapian.disown_ValueWeightPostingSource(self)
7516        return weakref_proxy(self)
7517ValueWeightPostingSource.get_weight = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValueWeightPostingSource_get_weight)
7518ValueWeightPostingSource.name = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValueWeightPostingSource_name)
7519ValueWeightPostingSource.init = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValueWeightPostingSource_init)
7520ValueWeightPostingSource.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValueWeightPostingSource___str__)
7521ValueWeightPostingSource_swigregister = _xapian.ValueWeightPostingSource_swigregister
7522ValueWeightPostingSource_swigregister(ValueWeightPostingSource)
7523
7524class DecreasingValueWeightPostingSource(ValueWeightPostingSource):
7525    """
7526
7527
7528    Read weights from a value which is known to decrease as docid
7529    increases.
7530
7531    This posting source can be used, like ValueWeightPostingSource, to add
7532    a weight contribution to a query based on the values stored in a slot.
7533    The values in the slot must be serialised as by  sortable_serialise().
7534
7535    However, this posting source is additionally given a range of document
7536    IDs, within which the weight is known to be decreasing. ie, for all
7537    documents with ids A and B within this range (including the
7538    endpoints), where A is less than B, the weight of A is less than or
7539    equal to the weight of B. This can allow the posting source to skip to
7540    the end of the range quickly if insufficient weight is left in the
7541    posting source for a particular source.
7542
7543    By default, the range is assumed to cover all document IDs.
7544
7545    The ordering property can be arranged at index time, or by sorting an
7546    indexed database to produce a new, sorted, database.
7547    """
7548
7549    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
7550    __repr__ = _swig_repr
7551
7552    def __init__(self, slot_, range_start_=0, range_end_=0):
7553        """
7554
7555
7556        Construct a DecreasingValueWeightPostingSource.
7557
7558        Xapian::DecreasingValueWeightPostingSource::DecreasingValueWeightPostingSource(Xapian::valueno
7559        slot_, Xapian::docid range_start_=0, Xapian::docid range_end_=0)
7560
7561        Parameters:
7562        -----------
7563
7564        slot_:  The value slot to read values from.
7565
7566        range_start_:  Start of range of docids for which weights are known to
7567        be decreasing (default: first docid)
7568
7569        range_end_:  End of range of docids for which weights are known to be
7570        decreasing (default: last docid)
7571        """
7572        _xapian.DecreasingValueWeightPostingSource_swiginit(self, _xapian.new_DecreasingValueWeightPostingSource(slot_, range_start_, range_end_))
7573    __swig_destroy__ = _xapian.delete_DecreasingValueWeightPostingSource
7574DecreasingValueWeightPostingSource_swigregister = _xapian.DecreasingValueWeightPostingSource_swigregister
7575DecreasingValueWeightPostingSource_swigregister(DecreasingValueWeightPostingSource)
7576
7577class ValueMapPostingSource(ValuePostingSource):
7578    """
7579
7580
7581    A posting source which looks up weights in a map using values as the
7582    key.
7583
7584    This allows will return entries for all documents in the given
7585    database which have a value in the slot specified. The values will be
7586    mapped to the corresponding weight in the weight map. If there is no
7587    mapping for a particular value, the default weight will be returned
7588    (which itself defaults to 0.0).
7589    """
7590
7591    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
7592    __repr__ = _swig_repr
7593
7594    def __init__(self, slot_):
7595        """
7596
7597
7598        Construct a ValueMapPostingSource.
7599
7600        Xapian::ValueMapPostingSource::ValueMapPostingSource(Xapian::valueno
7601        slot_)
7602
7603        Parameters:
7604        -----------
7605
7606        slot_:  The value slot to read values from.
7607        """
7608        _xapian.ValueMapPostingSource_swiginit(self, _xapian.new_ValueMapPostingSource(slot_))
7609
7610    def add_mapping(self, key, wt):
7611        """
7612
7613
7614        Add a mapping.
7615
7616        void Xapian::ValueMapPostingSource::add_mapping(const std::string
7617        &key, double wt)
7618
7619        Parameters:
7620        -----------
7621
7622        key:  The key looked up from the value slot.
7623
7624        wt:  The weight to give this key.
7625        """
7626        return _xapian.ValueMapPostingSource_add_mapping(self, key, wt)
7627
7628
7629    def clear_mappings(self):
7630        """
7631
7632
7633        Clear all mappings.
7634
7635        void Xapian::ValueMapPostingSource::clear_mappings()
7636        """
7637        return _xapian.ValueMapPostingSource_clear_mappings(self)
7638
7639
7640    def set_default_weight(self, wt):
7641        """
7642
7643
7644        Set a default weight for document values not in the map.
7645
7646        void Xapian::ValueMapPostingSource::set_default_weight(double wt)
7647
7648        Parameters:
7649        -----------
7650
7651        wt:  The weight to set as the default.
7652        """
7653        return _xapian.ValueMapPostingSource_set_default_weight(self, wt)
7654
7655    __swig_destroy__ = _xapian.delete_ValueMapPostingSource
7656ValueMapPostingSource.add_mapping = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValueMapPostingSource_add_mapping)
7657ValueMapPostingSource.clear_mappings = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValueMapPostingSource_clear_mappings)
7658ValueMapPostingSource.set_default_weight = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValueMapPostingSource_set_default_weight)
7659ValueMapPostingSource_swigregister = _xapian.ValueMapPostingSource_swigregister
7660ValueMapPostingSource_swigregister(ValueMapPostingSource)
7661
7662class FixedWeightPostingSource(PostingSource):
7663    """
7664
7665
7666    A posting source which returns a fixed weight for all documents.
7667
7668    This returns entries for all documents in the given database, with a
7669    fixed weight (specified by a parameter to the constructor).
7670    """
7671
7672    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
7673    __repr__ = _swig_repr
7674
7675    def __init__(self, wt):
7676        """
7677
7678
7679        Construct a FixedWeightPostingSource.
7680
7681        Xapian::FixedWeightPostingSource::FixedWeightPostingSource(double wt)
7682
7683        Parameters:
7684        -----------
7685
7686        wt:  The fixed weight to return.
7687        """
7688        _xapian.FixedWeightPostingSource_swiginit(self, _xapian.new_FixedWeightPostingSource(wt))
7689    __swig_destroy__ = _xapian.delete_FixedWeightPostingSource
7690FixedWeightPostingSource_swigregister = _xapian.FixedWeightPostingSource_swigregister
7691FixedWeightPostingSource_swigregister(FixedWeightPostingSource)
7692
7693class MatchSpy(object):
7694    """
7695
7696
7697    Abstract base class for match spies.
7698
7699    The subclasses will generally accumulate information seen during the
7700    match, to calculate aggregate functions, or other profiles of the
7701    matching documents.
7702    """
7703
7704    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
7705    __repr__ = _swig_repr
7706
7707    def __init__(self):
7708        """
7709
7710
7711        Default constructor, needed by subclass constructors.
7712
7713        Xapian::MatchSpy::MatchSpy()
7714        """
7715        if self.__class__ == MatchSpy:
7716            _self = None
7717        else:
7718            _self = self
7719        _xapian.MatchSpy_swiginit(self, _xapian.new_MatchSpy(_self, ))
7720    __swig_destroy__ = _xapian.delete_MatchSpy
7721
7722    def name(self):
7723        """
7724
7725
7726        Return the name of this match spy.
7727
7728        virtual std::string Xapian::MatchSpy::name() const
7729
7730        This name is used by the remote backend. It is passed with the
7731        serialised parameters to the remote server so that it knows which
7732        class to create.
7733
7734        Return the full namespace-qualified name of your class here - if your
7735        class is called MyApp::FooMatchSpy, return "MyApp::FooMatchSpy" from
7736        this method.
7737
7738        If you don't want to support the remote backend in your match spy, you
7739        can use the default implementation which simply throws
7740        Xapian::UnimplementedError.
7741        """
7742        return _xapian.MatchSpy_name(self)
7743
7744
7745    def merge_results(self, serialised):
7746        """
7747
7748
7749        Unserialise some results, and merge them into this matchspy.
7750
7751        virtual void Xapian::MatchSpy::merge_results(const std::string
7752        &serialised)
7753
7754        The order in which results are merged should not be significant, since
7755        this order is not specified (and will vary depending on the speed of
7756        the search in each sub-database).
7757
7758        If you don't want to support the remote backend in your match spy, you
7759        can use the default implementation which simply throws
7760        Xapian::UnimplementedError.
7761
7762        Parameters:
7763        -----------
7764
7765        serialised:  A string containing the serialised results.
7766        """
7767        return _xapian.MatchSpy_merge_results(self, serialised)
7768
7769
7770    def __str__(self):
7771        """
7772
7773
7774        Return a string describing this object.
7775
7776        virtual std::string Xapian::MatchSpy::get_description() const
7777
7778        This default implementation returns a generic answer, to avoid forcing
7779        those deriving their own MatchSpy subclasses from having to implement
7780        this (they may not care what get_description() gives for their
7781        subclass).
7782        """
7783        return _xapian.MatchSpy___str__(self)
7784
7785
7786    def release(self):
7787        """
7788
7789
7790        Start reference counting this object.
7791
7792        const MatchSpy* Xapian::MatchSpy::release() const
7793
7794        You can hand ownership of a dynamically allocated MatchSpy object to
7795        Xapian by calling release() and then passing the object to a Xapian
7796        method. Xapian will arrange to delete the object once it is no longer
7797        required.
7798        """
7799        return _xapian.MatchSpy_release(self)
7800
7801    def __disown__(self):
7802        self.this.disown()
7803        _xapian.disown_MatchSpy(self)
7804        return weakref_proxy(self)
7805MatchSpy.__call__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.MatchSpy___call__)
7806MatchSpy.name = _xapian.SWIG_PyInstanceMethod_New(_xapian.MatchSpy_name)
7807MatchSpy.merge_results = _xapian.SWIG_PyInstanceMethod_New(_xapian.MatchSpy_merge_results)
7808MatchSpy.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.MatchSpy___str__)
7809MatchSpy.release = _xapian.SWIG_PyInstanceMethod_New(_xapian.MatchSpy_release)
7810MatchSpy_swigregister = _xapian.MatchSpy_swigregister
7811MatchSpy_swigregister(MatchSpy)
7812
7813class ValueCountMatchSpy(MatchSpy):
7814    """
7815
7816
7817    Class for counting the frequencies of values in the matching
7818    documents.
7819    """
7820
7821    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
7822    __repr__ = _swig_repr
7823
7824    def __init__(self, *args):
7825        """
7826
7827
7828        Construct a MatchSpy which counts the values in a particular slot.
7829
7830        Xapian::ValueCountMatchSpy::ValueCountMatchSpy(Xapian::valueno slot_)
7831
7832        """
7833        _xapian.ValueCountMatchSpy_swiginit(self, _xapian.new_ValueCountMatchSpy(*args))
7834
7835    def get_total(self):
7836        """
7837
7838
7839        Return the total number of documents tallied.
7840
7841        size_t Xapian::ValueCountMatchSpy::get_total() const
7842        """
7843        return _xapian.ValueCountMatchSpy_get_total(self)
7844
7845
7846    def values_begin(self):
7847        """
7848
7849
7850        Get an iterator over the values seen in the slot.
7851
7852        TermIterator Xapian::ValueCountMatchSpy::values_begin() const
7853
7854        Items will be returned in ascending alphabetical order.
7855
7856        During the iteration, the frequency of the current value can be
7857        obtained with the get_termfreq() method on the iterator.
7858        """
7859        return _xapian.ValueCountMatchSpy_values_begin(self)
7860
7861
7862    def values_end(self):
7863        """
7864
7865
7866        End iterator corresponding to values_begin()
7867
7868        TermIterator Xapian::ValueCountMatchSpy::values_end() const
7869        """
7870        return _xapian.ValueCountMatchSpy_values_end(self)
7871
7872
7873    def top_values_begin(self, maxvalues):
7874        """
7875
7876
7877        Get an iterator over the most frequent values seen in the slot.
7878
7879        TermIterator Xapian::ValueCountMatchSpy::top_values_begin(size_t
7880        maxvalues) const
7881
7882        Items will be returned in descending order of frequency. Values with
7883        the same frequency will be returned in ascending alphabetical order.
7884
7885        During the iteration, the frequency of the current value can be
7886        obtained with the get_termfreq() method on the iterator.
7887
7888        Parameters:
7889        -----------
7890
7891        maxvalues:  The maximum number of values to return.
7892        """
7893        return _xapian.ValueCountMatchSpy_top_values_begin(self, maxvalues)
7894
7895
7896    def top_values_end(self, arg2):
7897        """
7898
7899
7900        End iterator corresponding to top_values_begin()
7901
7902        TermIterator Xapian::ValueCountMatchSpy::top_values_end(size_t) const
7903
7904        """
7905        return _xapian.ValueCountMatchSpy_top_values_end(self, arg2)
7906
7907    __swig_destroy__ = _xapian.delete_ValueCountMatchSpy
7908ValueCountMatchSpy.get_total = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValueCountMatchSpy_get_total)
7909ValueCountMatchSpy.values_begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValueCountMatchSpy_values_begin)
7910ValueCountMatchSpy.values_end = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValueCountMatchSpy_values_end)
7911ValueCountMatchSpy.top_values_begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValueCountMatchSpy_top_values_begin)
7912ValueCountMatchSpy.top_values_end = _xapian.SWIG_PyInstanceMethod_New(_xapian.ValueCountMatchSpy_top_values_end)
7913ValueCountMatchSpy_swigregister = _xapian.ValueCountMatchSpy_swigregister
7914ValueCountMatchSpy_swigregister(ValueCountMatchSpy)
7915
7916
7917def miles_to_metres(miles):
7918    return _xapian.miles_to_metres(miles)
7919miles_to_metres = _xapian.miles_to_metres
7920
7921def metres_to_miles(metres):
7922    return _xapian.metres_to_miles(metres)
7923metres_to_miles = _xapian.metres_to_miles
7924class LatLongCoord(object):
7925    """
7926
7927
7928    A latitude-longitude coordinate.
7929
7930    Experimental - seehttps://xapian.org/docs/deprecation#experimental-
7931    features
7932
7933    Note that latitude-longitude coordinates are only precisely meaningful
7934    if the datum used to define them is specified. This class ignores this
7935    issue - it is up to the caller to ensure that the datum used for each
7936    coordinate in a system is consistent.
7937    """
7938
7939    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
7940    __repr__ = _swig_repr
7941    latitude = property(_xapian.LatLongCoord_latitude_get, _xapian.LatLongCoord_latitude_set)
7942    longitude = property(_xapian.LatLongCoord_longitude_get, _xapian.LatLongCoord_longitude_set)
7943
7944    def __init__(self, *args):
7945        """
7946
7947
7948        Construct a coordinate.
7949
7950        Xapian::LatLongCoord::LatLongCoord(double latitude_, double
7951        longitude_)
7952
7953        If the supplied longitude is out of the standard range, it will be
7954        normalised to the range 0 <= longitude < 360.
7955
7956        If you want to avoid the checks (for example, you know that your
7957        values are already in range), you can use the alternate constructor to
7958        construct an uninitialised coordinate, and then set the latitude and
7959        longitude directly.
7960
7961        Parameters:
7962        -----------
7963
7964        InvalidArgumentError:  the supplied latitude is out of range.
7965        """
7966        _xapian.LatLongCoord_swiginit(self, _xapian.new_LatLongCoord(*args))
7967
7968    def unserialise(self, serialised):
7969        """
7970
7971
7972        Unserialise a buffer and set this object to its coordinate.
7973
7974        void Xapian::LatLongCoord::unserialise(const char **ptr, const char
7975        *end)
7976
7977        The buffer may contain further data after that for the coordinate.
7978
7979        Parameters:
7980        -----------
7981
7982        ptr:  A pointer to the start of the string. This will be updated to
7983        point to the end of the data representing the coordinate.
7984
7985        end:  A pointer to the end of the string.
7986
7987        Parameters:
7988        -----------
7989
7990        Xapian::SerialisationError:  if the string does not start with a valid
7991        serialised latitude- longitude pair.
7992        """
7993        return _xapian.LatLongCoord_unserialise(self, serialised)
7994
7995
7996    def serialise(self):
7997        """
7998
7999
8000        Return a serialised representation of the coordinate.
8001
8002        std::string Xapian::LatLongCoord::serialise() const
8003        """
8004        return _xapian.LatLongCoord_serialise(self)
8005
8006
8007    def __str__(self):
8008        """
8009
8010
8011        Return a string describing this object.
8012
8013        std::string Xapian::LatLongCoord::get_description() const
8014        """
8015        return _xapian.LatLongCoord___str__(self)
8016
8017    __swig_destroy__ = _xapian.delete_LatLongCoord
8018LatLongCoord.unserialise = _xapian.SWIG_PyInstanceMethod_New(_xapian.LatLongCoord_unserialise)
8019LatLongCoord.serialise = _xapian.SWIG_PyInstanceMethod_New(_xapian.LatLongCoord_serialise)
8020LatLongCoord.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.LatLongCoord___str__)
8021LatLongCoord_swigregister = _xapian.LatLongCoord_swigregister
8022LatLongCoord_swigregister(LatLongCoord)
8023
8024class LatLongCoordsIterator(object):
8025    """
8026
8027
8028    An iterator across the values in a LatLongCoords object.
8029
8030    Experimental - seehttps://xapian.org/docs/deprecation#experimental-
8031    features
8032    """
8033
8034    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
8035    __repr__ = _swig_repr
8036
8037    def __init__(self):
8038        """
8039
8040
8041        Default constructor. Produces an uninitialised iterator.
8042
8043        Xapian::LatLongCoordsIterator::LatLongCoordsIterator()
8044        """
8045        _xapian.LatLongCoordsIterator_swiginit(self, _xapian.new_LatLongCoordsIterator())
8046    __swig_destroy__ = _xapian.delete_LatLongCoordsIterator
8047LatLongCoordsIterator.__eq__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.LatLongCoordsIterator___eq__)
8048LatLongCoordsIterator.equals = _xapian.SWIG_PyInstanceMethod_New(_xapian.LatLongCoordsIterator_equals)
8049LatLongCoordsIterator.get_coord = _xapian.SWIG_PyInstanceMethod_New(_xapian.LatLongCoordsIterator_get_coord)
8050LatLongCoordsIterator.__next__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.LatLongCoordsIterator___next__)
8051LatLongCoordsIterator_swigregister = _xapian.LatLongCoordsIterator_swigregister
8052LatLongCoordsIterator_swigregister(LatLongCoordsIterator)
8053
8054class LatLongCoords(object):
8055    """
8056
8057
8058    A sequence of latitude-longitude coordinates.
8059
8060    Experimental - seehttps://xapian.org/docs/deprecation#experimental-
8061    features
8062    """
8063
8064    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
8065    __repr__ = _swig_repr
8066
8067    def begin(self):
8068        """
8069
8070
8071        Get a begin iterator for the coordinates.
8072
8073        LatLongCoordsIterator Xapian::LatLongCoords::begin() const
8074        """
8075        return _xapian.LatLongCoords_begin(self)
8076
8077
8078    def end(self):
8079        """
8080
8081
8082        Get an end iterator for the coordinates.
8083
8084        LatLongCoordsIterator Xapian::LatLongCoords::end() const
8085        """
8086        return _xapian.LatLongCoords_end(self)
8087
8088
8089    def size(self):
8090        """
8091
8092
8093        Get the number of coordinates in the container.
8094
8095        size_t Xapian::LatLongCoords::size() const
8096        """
8097        return _xapian.LatLongCoords_size(self)
8098
8099
8100    def empty(self):
8101        """
8102
8103
8104        Return true if and only if there are no coordinates in the container.
8105
8106        bool Xapian::LatLongCoords::empty() const
8107        """
8108        return _xapian.LatLongCoords_empty(self)
8109
8110
8111    def append(self, coord):
8112        """
8113
8114
8115        Append a coordinate to the end of the sequence.
8116
8117        void Xapian::LatLongCoords::append(const LatLongCoord &coord)
8118        """
8119        return _xapian.LatLongCoords_append(self, coord)
8120
8121
8122    def __init__(self, *args):
8123        """
8124
8125
8126        Construct a container holding one coordinate.
8127
8128        Xapian::LatLongCoords::LatLongCoords(const LatLongCoord &coord)
8129        """
8130        _xapian.LatLongCoords_swiginit(self, _xapian.new_LatLongCoords(*args))
8131
8132    def unserialise(self, serialised):
8133        """
8134
8135
8136        Unserialise a string and set this object to the coordinates in it.
8137
8138        void Xapian::LatLongCoords::unserialise(const std::string &serialised)
8139
8140        Parameters:
8141        -----------
8142
8143        serialised:  the string to unserialise the coordinates from.
8144
8145        Parameters:
8146        -----------
8147
8148        Xapian::SerialisationError:  if the string does not contain a valid
8149        serialised latitude-longitude pair, or contains junk at the end of it.
8150
8151        """
8152        return _xapian.LatLongCoords_unserialise(self, serialised)
8153
8154
8155    def serialise(self):
8156        """
8157
8158
8159        Return a serialised form of the coordinate list.
8160
8161        std::string Xapian::LatLongCoords::serialise() const
8162        """
8163        return _xapian.LatLongCoords_serialise(self)
8164
8165
8166    def __str__(self):
8167        """
8168
8169
8170        Return a string describing this object.
8171
8172        std::string Xapian::LatLongCoords::get_description() const
8173        """
8174        return _xapian.LatLongCoords___str__(self)
8175
8176    __swig_destroy__ = _xapian.delete_LatLongCoords
8177LatLongCoords.begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.LatLongCoords_begin)
8178LatLongCoords.end = _xapian.SWIG_PyInstanceMethod_New(_xapian.LatLongCoords_end)
8179LatLongCoords.size = _xapian.SWIG_PyInstanceMethod_New(_xapian.LatLongCoords_size)
8180LatLongCoords.empty = _xapian.SWIG_PyInstanceMethod_New(_xapian.LatLongCoords_empty)
8181LatLongCoords.append = _xapian.SWIG_PyInstanceMethod_New(_xapian.LatLongCoords_append)
8182LatLongCoords.unserialise = _xapian.SWIG_PyInstanceMethod_New(_xapian.LatLongCoords_unserialise)
8183LatLongCoords.serialise = _xapian.SWIG_PyInstanceMethod_New(_xapian.LatLongCoords_serialise)
8184LatLongCoords.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.LatLongCoords___str__)
8185LatLongCoords_swigregister = _xapian.LatLongCoords_swigregister
8186LatLongCoords_swigregister(LatLongCoords)
8187
8188
8189def __ne__(*args):
8190    return _xapian.__ne__(*args)
8191__ne__ = _xapian.__ne__
8192class LatLongMetric(object):
8193    """
8194
8195
8196    Base class for calculating distances between two lat/long coordinates.
8197
8198    Experimental - seehttps://xapian.org/docs/deprecation#experimental-
8199    features
8200    """
8201
8202    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
8203    __repr__ = _swig_repr
8204    __swig_destroy__ = _xapian.delete_LatLongMetric
8205
8206    def pointwise_distance(self, a, b):
8207        """
8208
8209
8210        Return the distance between two coordinates, in metres.
8211
8212        virtual double Xapian::LatLongMetric::pointwise_distance(const
8213        LatLongCoord &a, const LatLongCoord &b) const =0
8214        """
8215        return _xapian.LatLongMetric_pointwise_distance(self, a, b)
8216
8217
8218    def name(self):
8219        """
8220
8221
8222        Return the full name of the metric.
8223
8224        virtual std::string Xapian::LatLongMetric::name() const =0
8225
8226        This is used when serialising and unserialising metrics; for example,
8227        for performing remote searches.
8228
8229        If the subclass is in a C++ namespace, the namespace should be
8230        included in the name, using "::" as a separator. For example, for a
8231        LatLongMetric subclass called "FooLatLongMetric" in the "Xapian"
8232        namespace the result of this call should be
8233        "Xapian::FooLatLongMetric".
8234        """
8235        return _xapian.LatLongMetric_name(self)
8236
8237
8238    def __init__(self):
8239        if self.__class__ == LatLongMetric:
8240            _self = None
8241        else:
8242            _self = self
8243        _xapian.LatLongMetric_swiginit(self, _xapian.new_LatLongMetric(_self, ))
8244    def __disown__(self):
8245        self.this.disown()
8246        _xapian.disown_LatLongMetric(self)
8247        return weakref_proxy(self)
8248LatLongMetric.pointwise_distance = _xapian.SWIG_PyInstanceMethod_New(_xapian.LatLongMetric_pointwise_distance)
8249LatLongMetric.__call__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.LatLongMetric___call__)
8250LatLongMetric.name = _xapian.SWIG_PyInstanceMethod_New(_xapian.LatLongMetric_name)
8251LatLongMetric_swigregister = _xapian.LatLongMetric_swigregister
8252LatLongMetric_swigregister(LatLongMetric)
8253
8254class GreatCircleMetric(LatLongMetric):
8255    """
8256
8257
8258    Calculate the great-circle distance between two coordinates on a
8259    sphere.
8260
8261    Experimental - seehttps://xapian.org/docs/deprecation#experimental-
8262    features
8263
8264    This uses the haversine formula to calculate the distance. Note that
8265    this formula is subject to inaccuracy due to numerical errors for
8266    coordinates on the opposite side of the sphere.
8267
8268    Seehttps://en.wikipedia.org/wiki/Haversine_formula
8269    """
8270
8271    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
8272    __repr__ = _swig_repr
8273
8274    def __init__(self, *args):
8275        """
8276
8277
8278        Construct a GreatCircleMetric using a specified radius.
8279
8280        Xapian::GreatCircleMetric::GreatCircleMetric(double radius_)
8281
8282        This is useful for data sets in which the points are not on Earth (eg,
8283        a database of features on Mars).
8284
8285        Parameters:
8286        -----------
8287
8288        radius_:  The radius of the sphere to use, in metres.
8289        """
8290        _xapian.GreatCircleMetric_swiginit(self, _xapian.new_GreatCircleMetric(*args))
8291    __swig_destroy__ = _xapian.delete_GreatCircleMetric
8292GreatCircleMetric_swigregister = _xapian.GreatCircleMetric_swigregister
8293GreatCircleMetric_swigregister(GreatCircleMetric)
8294
8295class LatLongDistancePostingSource(ValuePostingSource):
8296    """
8297
8298
8299    Posting source which returns a weight based on geospatial distance.
8300
8301    Experimental - seehttps://xapian.org/docs/deprecation#experimental-
8302    features
8303
8304    Results are weighted by the distance from a fixed point, or list of
8305    points, calculated according to the metric supplied. If multiple
8306    points are supplied (either in the constructor, or in the coordinates
8307    stored in a document), the closest pointwise distance is used.
8308
8309    Documents further away than a specified maximum range (or with no
8310    location stored in the specified slot) will not be returned.
8311
8312    The weight returned is computed from the distance using the formula:
8313
8314    k1 * pow(distance + k1, -k2)
8315
8316    (Where k1 and k2 are (strictly) positive, floating point constants,
8317    which default to 1000 and 1, respectively. Distance is measured in
8318    metres, so this means that something at the centre gets a weight of
8319    1.0, something 1km away gets a weight of 0.5, and something 3km away
8320    gets a weight of 0.25, etc)
8321    """
8322
8323    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
8324    __repr__ = _swig_repr
8325
8326    def __init__(self, *args):
8327        """
8328
8329
8330        Construct a new posting source which returns only documents within
8331        range of one of the central coordinates.
8332
8333        Xapian::LatLongDistancePostingSource::LatLongDistancePostingSource(Xapian::valueno
8334        slot_, const LatLongCoords &centre_, double max_range_=0.0, double
8335        k1_=1000.0, double k2_=1.0)
8336
8337        Parameters:
8338        -----------
8339
8340        slot_:  The value slot to read values from.
8341
8342        centre_:  The centre point to use for distance calculations.
8343
8344        max_range_:  The maximum distance for documents which are returned.
8345
8346        k1_:  The k1 constant to use in the weighting function.
8347
8348        k2_:  The k2 constant to use in the weighting function.
8349
8350        Xapian::GreatCircleMetric is used as the metric.
8351        """
8352        _xapian.LatLongDistancePostingSource_swiginit(self, _xapian.new_LatLongDistancePostingSource(*args))
8353    __swig_destroy__ = _xapian.delete_LatLongDistancePostingSource
8354LatLongDistancePostingSource_swigregister = _xapian.LatLongDistancePostingSource_swigregister
8355LatLongDistancePostingSource_swigregister(LatLongDistancePostingSource)
8356
8357class LatLongDistanceKeyMaker(KeyMaker):
8358    """
8359
8360
8361    KeyMaker subclass which sorts by distance from a latitude/longitude.
8362
8363    Experimental - seehttps://xapian.org/docs/deprecation#experimental-
8364    features
8365
8366    Results are ordered by the distance from a fixed point, or list of
8367    points, calculated according to the metric supplied. If multiple
8368    points are supplied (either in the constructor, or in the coordinates
8369    stored in a document), the closest pointwise distance is used.
8370
8371    If a document contains no coordinate stored in the specified slot, a
8372    special value for the distance will be used. This defaults to a large
8373    number, so that such results get a low rank, but may be specified by a
8374    constructor parameter.
8375    """
8376
8377    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
8378    __repr__ = _swig_repr
8379
8380    def __init__(self, *args):
8381        """
8382
8383
8384        Construct a LatLongDistanceKeyMaker.
8385
8386        Xapian::LatLongDistanceKeyMaker::LatLongDistanceKeyMaker(Xapian::valueno
8387        slot_, const LatLongCoord &centre_)
8388
8389        Parameters:
8390        -----------
8391
8392        slot_:  Value slot to use.
8393
8394        centre_:  Point to calculate distance from.
8395
8396        Xapian::GreatCircleMetric is used as the metric.
8397
8398        Documents where no value is set are assumed to be a large distance
8399        away.
8400        """
8401        _xapian.LatLongDistanceKeyMaker_swiginit(self, _xapian.new_LatLongDistanceKeyMaker(*args))
8402    __swig_destroy__ = _xapian.delete_LatLongDistanceKeyMaker
8403LatLongDistanceKeyMaker_swigregister = _xapian.LatLongDistanceKeyMaker_swigregister
8404LatLongDistanceKeyMaker_swigregister(LatLongDistanceKeyMaker)
8405
8406class Database(object):
8407    """
8408
8409
8410    This class is used to access a database, or a group of databases.
8411
8412    For searching, this class is used in conjunction with an Enquire
8413    object.
8414
8415    Parameters:
8416    -----------
8417
8418    InvalidArgumentError:  will be thrown if an invalid argument is
8419    supplied, for example, an unknown database type.
8420
8421    DatabaseOpeningError:  may be thrown if the database cannot be opened
8422    (for example, a required file cannot be found).
8423
8424    DatabaseVersionError:  may be thrown if the database is in an
8425    unsupported format (for example, created by a newer version of Xapian
8426    which uses an incompatible format).
8427    """
8428
8429    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
8430    __repr__ = _swig_repr
8431
8432    def add_database(self, database):
8433        """
8434
8435
8436        Add an existing database (or group of databases) to those accessed by
8437        this object.
8438
8439        void Xapian::Database::add_database(const Database &database)
8440
8441        Parameters:
8442        -----------
8443
8444        database:  the database(s) to add.
8445        """
8446        return _xapian.Database_add_database(self, database)
8447
8448
8449    def size(self):
8450        """
8451
8452
8453        Return number of shards in this Database object.
8454
8455        size_t Xapian::Database::size() const
8456        """
8457        return _xapian.Database_size(self)
8458
8459
8460    def __init__(self, *args):
8461        """
8462
8463
8464        Copying is allowed.
8465
8466        Xapian::Database::Database(const Database &other)
8467
8468        The internals are reference counted, so copying is cheap.
8469
8470        Parameters:
8471        -----------
8472
8473        other:  The object to copy.
8474        """
8475        _xapian.Database_swiginit(self, _xapian.new_Database(*args))
8476    __swig_destroy__ = _xapian.delete_Database
8477
8478    def reopen(self):
8479        """
8480
8481
8482        Re-open the database.
8483
8484        bool Xapian::Database::reopen()
8485
8486        This re-opens the database(s) to the latest available version(s). It
8487        can be used either to make sure the latest results are returned, or to
8488        recover from a Xapian::DatabaseModifiedError.
8489
8490        Calling reopen() on a database which has been closed (with  close())
8491        will always raise a Xapian::DatabaseError.
8492
8493        true if the database might have been reopened (if false is returned,
8494        the database definitely hasn't been reopened, which applications may
8495        find useful when caching results, etc). In Xapian < 1.3.0, this method
8496        did not return a value.
8497        """
8498        return _xapian.Database_reopen(self)
8499
8500
8501    def close(self):
8502        """
8503
8504
8505        Close the database.
8506
8507        virtual void Xapian::Database::close()
8508
8509        This closes the database and closes all its file handles.
8510
8511        For a WritableDatabase, if a transaction is active it will be aborted,
8512        while if no transaction is active commit() will be implicitly called.
8513        Also the write lock is released.
8514
8515        Closing a database cannot be undone - in particular, calling reopen()
8516        after close() will not reopen it, but will instead throw a
8517        Xapian::DatabaseError exception.
8518
8519        Calling close() again on a database which has already been closed has
8520        no effect (and doesn't raise an exception).
8521
8522        After close() has been called, calls to other methods of the database,
8523        and to methods of other objects associated with the database, will
8524        either:
8525
8526        behave exactly as they would have done if the database had not been
8527        closed (this can only happen if all the required data is cached)
8528
8529        raise a Xapian::DatabaseError exception indicating that the database
8530        is closed.
8531
8532        The reason for this behaviour is that otherwise we'd have to check
8533        that the database is still open on every method call on every object
8534        associated with a Database, when in many cases they are working on
8535        data which has already been loaded and so they are able to just behave
8536        correctly.
8537
8538        This method was added in Xapian 1.1.0.
8539        """
8540        return _xapian.Database_close(self)
8541
8542
8543    def __str__(self):
8544        """
8545
8546
8547        Return a string describing this object.
8548
8549        virtual std::string Xapian::Database::get_description() const
8550        """
8551        return _xapian.Database___str__(self)
8552
8553
8554    def _postlist_begin(self, tname):
8555        """
8556
8557
8558        An iterator pointing to the start of the postlist for a given term.
8559
8560        PostingIterator Xapian::Database::postlist_begin(const std::string
8561        &tname) const
8562
8563        Parameters:
8564        -----------
8565
8566        tname:  The termname to iterate postings for. If the term name is the
8567        empty string, the iterator returned will list all the documents in the
8568        database. Such an iterator will always return a WDF value of 1, since
8569        there is no obvious meaning for this quantity in this case.
8570        """
8571        return _xapian.Database__postlist_begin(self, tname)
8572
8573
8574    def _postlist_end(self, arg2):
8575        """
8576
8577
8578        Corresponding end iterator to postlist_begin().
8579
8580        PostingIterator Xapian::Database::postlist_end(const std::string &)
8581        const
8582        """
8583        return _xapian.Database__postlist_end(self, arg2)
8584
8585
8586    def _termlist_begin(self, did):
8587        """
8588
8589
8590        An iterator pointing to the start of the termlist for a given
8591        document.
8592
8593        TermIterator Xapian::Database::termlist_begin(Xapian::docid did) const
8594
8595        Parameters:
8596        -----------
8597
8598        did:  The document id of the document to iterate terms for.
8599        """
8600        return _xapian.Database__termlist_begin(self, did)
8601
8602
8603    def _termlist_end(self, arg2):
8604        """
8605
8606
8607        Corresponding end iterator to termlist_begin().
8608
8609        TermIterator Xapian::Database::termlist_end(Xapian::docid) const
8610        """
8611        return _xapian.Database__termlist_end(self, arg2)
8612
8613
8614    def has_positions(self):
8615        """
8616
8617
8618        Does this database have any positional information?
8619
8620        bool Xapian::Database::has_positions() const
8621        """
8622        return _xapian.Database_has_positions(self)
8623
8624
8625    def _positionlist_begin(self, did, tname):
8626        """
8627
8628
8629        An iterator pointing to the start of the position list for a given
8630        term in a given document.
8631
8632        PositionIterator Xapian::Database::positionlist_begin(Xapian::docid
8633        did, const std::string &tname) const
8634        """
8635        return _xapian.Database__positionlist_begin(self, did, tname)
8636
8637
8638    def _positionlist_end(self, arg2, arg3):
8639        """
8640
8641
8642        Corresponding end iterator to positionlist_begin().
8643
8644        PositionIterator Xapian::Database::positionlist_end(Xapian::docid,
8645        const std::string &) const
8646        """
8647        return _xapian.Database__positionlist_end(self, arg2, arg3)
8648
8649
8650    def _allterms_begin(self, *args):
8651        """
8652
8653
8654        An iterator which runs across all terms with a given prefix.
8655
8656        TermIterator Xapian::Database::allterms_begin(const std::string
8657        &prefix=std::string()) const
8658
8659        Parameters:
8660        -----------
8661
8662        prefix:  The prefix to restrict the returned terms to (default:
8663        iterate all terms)
8664        """
8665        return _xapian.Database__allterms_begin(self, *args)
8666
8667
8668    def _allterms_end(self, *args):
8669        """
8670
8671
8672        Corresponding end iterator to allterms_begin(prefix).
8673
8674        TermIterator Xapian::Database::allterms_end(const std::string
8675        &=std::string()) const
8676        """
8677        return _xapian.Database__allterms_end(self, *args)
8678
8679
8680    def get_doccount(self):
8681        """
8682
8683
8684        Get the number of documents in the database.
8685
8686        Xapian::doccount Xapian::Database::get_doccount() const
8687        """
8688        return _xapian.Database_get_doccount(self)
8689
8690
8691    def get_lastdocid(self):
8692        """
8693
8694
8695        Get the highest document id which has been used in the database.
8696
8697        Xapian::docid Xapian::Database::get_lastdocid() const
8698        """
8699        return _xapian.Database_get_lastdocid(self)
8700
8701
8702    def get_avlength(self):
8703        """
8704
8705
8706        Get the average length of the documents in the database.
8707
8708        Xapian::doclength Xapian::Database::get_avlength() const
8709        """
8710        return _xapian.Database_get_avlength(self)
8711
8712
8713    def get_average_length(self):
8714        """
8715
8716
8717        New name for get_avlength().
8718
8719        double Xapian::Database::get_average_length() const
8720
8721        Added for forward compatibility with the next release series.
8722
8723        1.4.17.
8724        """
8725        return _xapian.Database_get_average_length(self)
8726
8727
8728    def get_total_length(self):
8729        """
8730
8731
8732        Get the total length of all the documents in the database.
8733
8734        Xapian::totallength Xapian::Database::get_total_length() const
8735
8736        Added in Xapian 1.4.5.
8737        """
8738        return _xapian.Database_get_total_length(self)
8739
8740
8741    def get_termfreq(self, tname):
8742        """
8743
8744
8745        Get the number of documents in the database indexed by a given term.
8746
8747        Xapian::doccount Xapian::Database::get_termfreq(const std::string
8748        &tname) const
8749        """
8750        return _xapian.Database_get_termfreq(self, tname)
8751
8752
8753    def term_exists(self, tname):
8754        """
8755
8756
8757        Check if a given term exists in the database.
8758
8759        bool Xapian::Database::term_exists(const std::string &tname) const
8760
8761        Parameters:
8762        -----------
8763
8764        tname:  The term to test the existence of.
8765
8766        true if and only if the term exists in the database. This is the same
8767        as (get_termfreq(tname) != 0), but will often be more efficient.
8768        """
8769        return _xapian.Database_term_exists(self, tname)
8770
8771
8772    def get_collection_freq(self, tname):
8773        """
8774
8775
8776        Return the total number of occurrences of the given term.
8777
8778        Xapian::termcount Xapian::Database::get_collection_freq(const
8779        std::string &tname) const
8780
8781        This is the sum of the number of occurrences of the term in each
8782        document it indexes: i.e., the sum of the within document frequencies
8783        of the term.
8784
8785        Parameters:
8786        -----------
8787
8788        tname:  The term whose collection frequency is being requested.
8789        """
8790        return _xapian.Database_get_collection_freq(self, tname)
8791
8792
8793    def get_value_freq(self, slot):
8794        """
8795
8796
8797        Return the frequency of a given value slot.
8798
8799        Xapian::doccount Xapian::Database::get_value_freq(Xapian::valueno
8800        slot) const
8801
8802        This is the number of documents which have a (non-empty) value stored
8803        in the slot.
8804
8805        Parameters:
8806        -----------
8807
8808        slot:  The value slot to examine.
8809        """
8810        return _xapian.Database_get_value_freq(self, slot)
8811
8812
8813    def get_value_lower_bound(self, slot):
8814        """
8815
8816
8817        Get a lower bound on the values stored in the given value slot.
8818
8819        std::string Xapian::Database::get_value_lower_bound(Xapian::valueno
8820        slot) const
8821
8822        If there are no values stored in the given value slot, this will
8823        return an empty string.
8824
8825        Parameters:
8826        -----------
8827
8828        slot:  The value slot to examine.
8829        """
8830        return _xapian.Database_get_value_lower_bound(self, slot)
8831
8832
8833    def get_value_upper_bound(self, slot):
8834        """
8835
8836
8837        Get an upper bound on the values stored in the given value slot.
8838
8839        std::string Xapian::Database::get_value_upper_bound(Xapian::valueno
8840        slot) const
8841
8842        If there are no values stored in the given value slot, this will
8843        return an empty string.
8844
8845        Parameters:
8846        -----------
8847
8848        slot:  The value slot to examine.
8849        """
8850        return _xapian.Database_get_value_upper_bound(self, slot)
8851
8852
8853    def get_doclength_lower_bound(self):
8854        """
8855
8856
8857        Get a lower bound on the length of a document in this DB.
8858
8859        Xapian::termcount Xapian::Database::get_doclength_lower_bound() const
8860
8861        This bound does not include any zero-length documents.
8862        """
8863        return _xapian.Database_get_doclength_lower_bound(self)
8864
8865
8866    def get_doclength_upper_bound(self):
8867        """
8868
8869
8870        Get an upper bound on the length of a document in this DB.
8871
8872        Xapian::termcount Xapian::Database::get_doclength_upper_bound() const
8873
8874        """
8875        return _xapian.Database_get_doclength_upper_bound(self)
8876
8877
8878    def get_wdf_upper_bound(self, term):
8879        """
8880
8881
8882        Get an upper bound on the wdf of term term.
8883
8884        Xapian::termcount Xapian::Database::get_wdf_upper_bound(const
8885        std::string &term) const
8886        """
8887        return _xapian.Database_get_wdf_upper_bound(self, term)
8888
8889
8890    def valuestream_begin(self, slot):
8891        """
8892
8893
8894        Return an iterator over the value in slot slot for each document.
8895
8896        ValueIterator Xapian::Database::valuestream_begin(Xapian::valueno
8897        slot) const
8898        """
8899        return _xapian.Database_valuestream_begin(self, slot)
8900
8901
8902    def valuestream_end(self, arg2):
8903        """
8904
8905
8906        Return end iterator corresponding to valuestream_begin().
8907
8908        ValueIterator Xapian::Database::valuestream_end(Xapian::valueno) const
8909
8910        """
8911        return _xapian.Database_valuestream_end(self, arg2)
8912
8913
8914    def get_doclength(self, did):
8915        """
8916
8917
8918        Get the length of a document.
8919
8920        Xapian::termcount Xapian::Database::get_doclength(Xapian::docid did)
8921        const
8922        """
8923        return _xapian.Database_get_doclength(self, did)
8924
8925
8926    def get_unique_terms(self, did):
8927        """
8928
8929
8930        Get the number of unique terms in document.
8931
8932        Xapian::termcount Xapian::Database::get_unique_terms(Xapian::docid
8933        did) const
8934        """
8935        return _xapian.Database_get_unique_terms(self, did)
8936
8937
8938    def keep_alive(self):
8939        """
8940
8941
8942        Send a "keep-alive" to remote databases to stop them timing out.
8943
8944        void Xapian::Database::keep_alive()
8945
8946        Has no effect on non-remote databases.
8947        """
8948        return _xapian.Database_keep_alive(self)
8949
8950
8951    def get_document(self, *args):
8952        """
8953
8954
8955        Get a document from the database, given its document id.
8956
8957        Xapian::Document Xapian::Database::get_document(Xapian::docid did,
8958        unsigned flags) const
8959
8960        This method returns a Xapian::Document object which provides the
8961        information about a document.
8962
8963        Parameters:
8964        -----------
8965
8966        did:  The document id of the document to retrieve.
8967
8968        flags:  Zero or more flags bitwise-or-ed together (currently only
8969        Xapian::DOC_ASSUME_VALID is supported).
8970
8971        A Xapian::Document object containing the document data
8972
8973        Parameters:
8974        -----------
8975
8976        Xapian::DocNotFoundError:  The document specified could not be found
8977        in the database.
8978
8979        Xapian::InvalidArgumentError:  did was 0, which is not a valid
8980        document id.
8981        """
8982        return _xapian.Database_get_document(self, *args)
8983
8984
8985    def get_spelling_suggestion(self, word, max_edit_distance=2):
8986        """
8987
8988
8989        Suggest a spelling correction.
8990
8991        std::string Xapian::Database::get_spelling_suggestion(const
8992        std::string &word, unsigned max_edit_distance=2) const
8993
8994        Parameters:
8995        -----------
8996
8997        word:  The potentially misspelled word.
8998
8999        max_edit_distance:  Only consider words which are at most
9000        max_edit_distance edits from word. An edit is a character insertion,
9001        deletion, or the transposition of two adjacent characters (default is
9002        2).
9003        """
9004        return _xapian.Database_get_spelling_suggestion(self, word, max_edit_distance)
9005
9006
9007    def _spellings_begin(self):
9008        """
9009
9010
9011        An iterator which returns all the spelling correction targets.
9012
9013        Xapian::TermIterator Xapian::Database::spellings_begin() const
9014
9015        This returns all the words which are considered as targets for the
9016        spelling correction algorithm. The frequency of each word is available
9017        as the term frequency of each entry in the returned iterator.
9018        """
9019        return _xapian.Database__spellings_begin(self)
9020
9021
9022    def _spellings_end(self):
9023        """
9024
9025
9026        Corresponding end iterator to spellings_begin().
9027
9028        Xapian::TermIterator Xapian::Database::spellings_end() const
9029        """
9030        return _xapian.Database__spellings_end(self)
9031
9032
9033    def _synonyms_begin(self, term):
9034        """
9035
9036
9037        An iterator which returns all the synonyms for a given term.
9038
9039        Xapian::TermIterator Xapian::Database::synonyms_begin(const
9040        std::string &term) const
9041
9042        Parameters:
9043        -----------
9044
9045        term:  The term to return synonyms for.
9046        """
9047        return _xapian.Database__synonyms_begin(self, term)
9048
9049
9050    def _synonyms_end(self, arg2):
9051        """
9052
9053
9054        Corresponding end iterator to synonyms_begin(term).
9055
9056        Xapian::TermIterator Xapian::Database::synonyms_end(const std::string
9057        &) const
9058        """
9059        return _xapian.Database__synonyms_end(self, arg2)
9060
9061
9062    def _synonym_keys_begin(self, *args):
9063        """
9064
9065
9066        An iterator which returns all terms which have synonyms.
9067
9068        Xapian::TermIterator Xapian::Database::synonym_keys_begin(const
9069        std::string &prefix=std::string()) const
9070
9071        Parameters:
9072        -----------
9073
9074        prefix:  If non-empty, only terms with this prefix are returned.
9075        """
9076        return _xapian.Database__synonym_keys_begin(self, *args)
9077
9078
9079    def _synonym_keys_end(self, *args):
9080        """
9081
9082
9083        Corresponding end iterator to synonym_keys_begin(prefix).
9084
9085        Xapian::TermIterator Xapian::Database::synonym_keys_end(const
9086        std::string &=std::string()) const
9087        """
9088        return _xapian.Database__synonym_keys_end(self, *args)
9089
9090
9091    def get_metadata(self, key):
9092        """
9093
9094
9095        Get the user-specified metadata associated with a given key.
9096
9097        std::string Xapian::Database::get_metadata(const std::string &key)
9098        const
9099
9100        User-specified metadata allows you to store arbitrary information in
9101        the form of (key, value) pairs. See  WritableDatabase::set_metadata()
9102        for more information.
9103
9104        When invoked on a Xapian::Database object representing multiple
9105        databases, currently only the metadata for the first is considered but
9106        this behaviour may change in the future.
9107
9108        If there is no piece of metadata associated with the specified key, an
9109        empty string is returned (this applies even for backends which don't
9110        support metadata).
9111
9112        Empty keys are not valid, and specifying one will cause an exception.
9113
9114        Parameters:
9115        -----------
9116
9117        key:  The key of the metadata item to access.
9118
9119        The retrieved metadata item's value.
9120
9121        Parameters:
9122        -----------
9123
9124        Xapian::InvalidArgumentError:  will be thrown if the key supplied is
9125        empty.
9126        """
9127        return _xapian.Database_get_metadata(self, key)
9128
9129
9130    def _metadata_keys_begin(self, *args):
9131        """
9132
9133
9134        An iterator which returns all user-specified metadata keys.
9135
9136        Xapian::TermIterator Xapian::Database::metadata_keys_begin(const
9137        std::string &prefix=std::string()) const
9138
9139        When invoked on a Xapian::Database object representing multiple
9140        databases, currently only the metadata for the first is considered but
9141        this behaviour may change in the future.
9142
9143        If the backend doesn't support metadata, then this method returns an
9144        iterator which compares equal to that returned by metadata_keys_end().
9145
9146        Parameters:
9147        -----------
9148
9149        prefix:  If non-empty, only keys with this prefix are returned.
9150
9151        Parameters:
9152        -----------
9153
9154        Xapian::UnimplementedError:  will be thrown if the backend implements
9155        user-specified metadata, but doesn't implement iterating its keys
9156        (currently this happens for the InMemory backend).
9157        """
9158        return _xapian.Database__metadata_keys_begin(self, *args)
9159
9160
9161    def _metadata_keys_end(self, *args):
9162        """
9163
9164
9165        Corresponding end iterator to metadata_keys_begin().
9166
9167        Xapian::TermIterator Xapian::Database::metadata_keys_end(const
9168        std::string &=std::string()) const
9169        """
9170        return _xapian.Database__metadata_keys_end(self, *args)
9171
9172
9173    def get_uuid(self):
9174        """
9175
9176
9177        Get a UUID for the database.
9178
9179        std::string Xapian::Database::get_uuid() const
9180
9181        The UUID will persist for the lifetime of the database.
9182
9183        Replicas (eg, made with the replication protocol, or by copying all
9184        the database files) will have the same UUID. However, copies (made
9185        with copydatabase, or xapian-compact) will have different UUIDs.
9186
9187        If the backend does not support UUIDs or this database has no
9188        subdatabases, the UUID will be empty.
9189
9190        If this database has multiple sub-databases, the UUID string will
9191        contain the UUIDs of all the sub-databases.
9192        """
9193        return _xapian.Database_get_uuid(self)
9194
9195
9196    def locked(self):
9197        """
9198
9199
9200        Test if this database is currently locked for writing.
9201
9202        bool Xapian::Database::locked() const
9203
9204        If the underlying object is actually a WritableDatabase, always
9205        returns true.
9206
9207        Otherwise tests if there's a writer holding the lock (or if we can't
9208        test for a lock without taking it on the current platform, throw
9209        Xapian::UnimplementedError). If there's an error while trying to test
9210        the lock, throws Xapian::DatabaseLockError.
9211
9212        For multi-databases, this tests each sub-database and returns true if
9213        any of them are locked.
9214        """
9215        return _xapian.Database_locked(self)
9216
9217
9218    def get_revision(self):
9219        """
9220
9221
9222        Get the revision of the database.
9223
9224        Xapian::rev Xapian::Database::get_revision() const
9225
9226        The revision is an unsigned integer which increases with each commit.
9227
9228        The database must have exactly one sub-database, which must be of type
9229        chert or glass. Otherwise an exception will be thrown.
9230
9231        Experimental - seehttps://xapian.org/docs/deprecation#experimental-
9232        features
9233        """
9234        return _xapian.Database_get_revision(self)
9235
9236    check = staticmethod(_xapian.Database_check)
9237
9238    def compact(self, *args):
9239        """
9240
9241
9242        Produce a compact version of this database.
9243
9244        void Xapian::Database::compact(int fd, unsigned flags, int block_size,
9245        Xapian::Compactor &compactor)
9246
9247        New 1.3.4. Various methods of the Compactor class were deprecated in
9248        1.3.4.
9249
9250        The compactor functor allows handling progress output and specifying
9251        how user metadata is merged.
9252
9253        This variant writes a single-file database to the specified file
9254        descriptor. Only the glass backend supports such databases, so this
9255        form is only supported for this backend.
9256
9257        Parameters:
9258        -----------
9259
9260        fd:  File descriptor to write the compact version to. The descriptor
9261        needs to be readable and writable (open with O_RDWR) and seekable. The
9262        current file offset is used, allowing compacting to a single file
9263        database embedded within another file. Xapian takes ownership of the
9264        file descriptor and will close it before returning.
9265
9266        flags:  Any of the following combined using bitwise-or (| in C++):
9267        Xapian::DBCOMPACT_NO_RENUMBER By default the document ids will be
9268        renumbered the output - currently by applying the same offset to all
9269        the document ids in a particular source database. If this flag is
9270        specified, then this renumbering doesn't happen, but all the document
9271        ids must be unique over all source databases. Currently the ranges of
9272        document ids in each source must not overlap either, though this
9273        restriction may be removed in the future.
9274
9275        Xapian::DBCOMPACT_MULTIPASS If merging more than 3 databases, merge
9276        the postlists in multiple passes, which is generally faster but
9277        requires more disk space for temporary files.
9278
9279        Xapian::DBCOMPACT_SINGLE_FILE Produce a single-file database (only
9280        supported for glass currently) - this flag is implied in this form and
9281        need not be specified explicitly.
9282
9283        block_size:  This specifies the block size (in bytes) for to use for
9284        the output. For glass, the block size must be a power of 2 between
9285        2048 and 65536 (inclusive), and the default (also used if an invalid
9286        value is passed) is 8192 bytes.
9287
9288        compactor:  Functor
9289        """
9290        return _xapian.Database_compact(self, *args)
9291
9292Database.add_database = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_add_database)
9293Database.size = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_size)
9294Database.reopen = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_reopen)
9295Database.close = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_close)
9296Database.__str__ = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database___str__)
9297Database._postlist_begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database__postlist_begin)
9298Database._postlist_end = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database__postlist_end)
9299Database._termlist_begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database__termlist_begin)
9300Database._termlist_end = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database__termlist_end)
9301Database.has_positions = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_has_positions)
9302Database._positionlist_begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database__positionlist_begin)
9303Database._positionlist_end = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database__positionlist_end)
9304Database._allterms_begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database__allterms_begin)
9305Database._allterms_end = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database__allterms_end)
9306Database.get_doccount = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_get_doccount)
9307Database.get_lastdocid = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_get_lastdocid)
9308Database.get_avlength = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_get_avlength)
9309Database.get_average_length = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_get_average_length)
9310Database.get_total_length = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_get_total_length)
9311Database.get_termfreq = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_get_termfreq)
9312Database.term_exists = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_term_exists)
9313Database.get_collection_freq = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_get_collection_freq)
9314Database.get_value_freq = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_get_value_freq)
9315Database.get_value_lower_bound = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_get_value_lower_bound)
9316Database.get_value_upper_bound = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_get_value_upper_bound)
9317Database.get_doclength_lower_bound = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_get_doclength_lower_bound)
9318Database.get_doclength_upper_bound = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_get_doclength_upper_bound)
9319Database.get_wdf_upper_bound = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_get_wdf_upper_bound)
9320Database.valuestream_begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_valuestream_begin)
9321Database.valuestream_end = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_valuestream_end)
9322Database.get_doclength = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_get_doclength)
9323Database.get_unique_terms = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_get_unique_terms)
9324Database.keep_alive = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_keep_alive)
9325Database.get_document = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_get_document)
9326Database.get_spelling_suggestion = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_get_spelling_suggestion)
9327Database._spellings_begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database__spellings_begin)
9328Database._spellings_end = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database__spellings_end)
9329Database._synonyms_begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database__synonyms_begin)
9330Database._synonyms_end = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database__synonyms_end)
9331Database._synonym_keys_begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database__synonym_keys_begin)
9332Database._synonym_keys_end = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database__synonym_keys_end)
9333Database.get_metadata = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_get_metadata)
9334Database._metadata_keys_begin = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database__metadata_keys_begin)
9335Database._metadata_keys_end = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database__metadata_keys_end)
9336Database.get_uuid = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_get_uuid)
9337Database.locked = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_locked)
9338Database.get_revision = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_get_revision)
9339Database.compact = _xapian.SWIG_PyInstanceMethod_New(_xapian.Database_compact)
9340Database_swigregister = _xapian.Database_swigregister
9341Database_swigregister(Database)
9342
9343def Database_check(fd, opts=0, out=None):
9344    return _xapian.Database_check(fd, opts, out)
9345Database_check = _xapian.Database_check
9346
9347class WritableDatabase(Database):
9348    """
9349
9350
9351    This class provides read/write access to a database.
9352    """
9353
9354    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
9355    __repr__ = _swig_repr
9356    __swig_destroy__ = _xapian.delete_WritableDatabase
9357
9358    def __init__(self, *args):
9359        """
9360
9361
9362        Copying is allowed.
9363
9364        Xapian::WritableDatabase::WritableDatabase(const WritableDatabase
9365        &other)
9366
9367        The internals are reference counted, so copying is cheap.
9368
9369        Parameters:
9370        -----------
9371
9372        other:  The object to copy.
9373        """
9374        _xapian.WritableDatabase_swiginit(self, _xapian.new_WritableDatabase(*args))
9375
9376    def commit(self):
9377        """
9378
9379
9380        Commit any pending modifications made to the database.
9381
9382        void Xapian::WritableDatabase::commit()
9383
9384        For efficiency reasons, when performing multiple updates to a database
9385        it is best (indeed, almost essential) to make as many modifications as
9386        memory will permit in a single pass through the database. To ensure
9387        this, Xapian batches up modifications.
9388
9389        This method may be called at any time to commit any pending
9390        modifications to the database.
9391
9392        If any of the modifications fail, an exception will be thrown and the
9393        database will be left in a state in which each separate addition,
9394        replacement or deletion operation has either been fully performed or
9395        not performed at all: it is then up to the application to work out
9396        which operations need to be repeated.
9397
9398        It's not valid to call commit() within a transaction.
9399
9400        Beware of calling commit() too frequently: this will make indexing
9401        take much longer.
9402
9403        Note that commit() need not be called explicitly: it will be called
9404        automatically when the database is closed, or when a sufficient number
9405        of modifications have been made. By default, this is every 10000
9406        documents added, deleted, or modified. This value is rather
9407        conservative, and if you have a machine with plenty of memory, you can
9408        improve indexing throughput dramatically by setting
9409        XAPIAN_FLUSH_THRESHOLD in the environment to a larger value.
9410
9411        This method was new in Xapian 1.1.0 - in earlier versions it was
9412        called flush().
9413
9414        Parameters:
9415        -----------
9416
9417        Xapian::DatabaseError:  will be thrown if a problem occurs while
9418        modifying the database.
9419
9420        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
9421        corrupt state.
9422        """
9423        return _xapian.WritableDatabase_commit(self)
9424
9425
9426    def flush(self):
9427        """
9428
9429
9430        Pre-1.1.0 name for commit().
9431
9432        void Xapian::WritableDatabase::flush()
9433
9434        Use commit() instead.
9435        """
9436        return _xapian.WritableDatabase_flush(self)
9437
9438
9439    def begin_transaction(self, flushed=True):
9440        """
9441
9442
9443        Begin a transaction.
9444
9445        void Xapian::WritableDatabase::begin_transaction(bool flushed=true)
9446
9447        In Xapian a transaction is a group of modifications to the database
9448        which are linked such that either all will be applied simultaneously
9449        or none will be applied at all. Even in the case of a power failure,
9450        this characteristic should be preserved (as long as the filesystem
9451        isn't corrupted, etc).
9452
9453        A transaction is started with begin_transaction() and can either be
9454        committed by calling commit_transaction() or aborted by calling
9455        cancel_transaction().
9456
9457        By default, a transaction implicitly calls commit() before and after
9458        so that the modifications stand and fall without affecting
9459        modifications before or after.
9460
9461        The downside of these implicit calls to commit() is that small
9462        transactions can harm indexing performance in the same way that
9463        explicitly calling commit() frequently can.
9464
9465        If you're applying atomic groups of changes and only wish to ensure
9466        that each group is either applied or not applied, then you can prevent
9467        the automatic commit() before and after the transaction by starting
9468        the transaction with begin_transaction(false). However, if
9469        cancel_transaction is called (or if commit_transaction isn't called
9470        before the WritableDatabase object is destroyed) then any changes
9471        which were pending before the transaction began will also be
9472        discarded.
9473
9474        Transactions aren't currently supported by the InMemory backend.
9475
9476        Parameters:
9477        -----------
9478
9479        flushed:  Is this a flushed transaction? By default transactions are
9480        "flushed", which means that committing a transaction will ensure
9481        those changes are permanently written to the database. By contrast,
9482        unflushed transactions only ensure that changes within the transaction
9483        are either all applied or all aren't.
9484
9485        Parameters:
9486        -----------
9487
9488        Xapian::UnimplementedError:  will be thrown if transactions are not
9489        available for this database type.
9490
9491        Xapian::InvalidOperationError:  will be thrown if this is called at an
9492        invalid time, such as when a transaction is already in progress.
9493        """
9494        return _xapian.WritableDatabase_begin_transaction(self, flushed)
9495
9496
9497    def commit_transaction(self):
9498        """
9499
9500
9501        Complete the transaction currently in progress.
9502
9503        void Xapian::WritableDatabase::commit_transaction()
9504
9505        If this method completes successfully and this is a flushed
9506        transaction, all the database modifications made during the
9507        transaction will have been committed to the database.
9508
9509        If an error occurs, an exception will be thrown, and none of the
9510        modifications made to the database during the transaction will have
9511        been applied to the database.
9512
9513        In all cases the transaction will no longer be in progress.
9514
9515        Parameters:
9516        -----------
9517
9518        Xapian::DatabaseError:  will be thrown if a problem occurs while
9519        modifying the database.
9520
9521        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
9522        corrupt state.
9523
9524        Xapian::InvalidOperationError:  will be thrown if a transaction is not
9525        currently in progress.
9526
9527        Xapian::UnimplementedError:  will be thrown if transactions are not
9528        available for this database type.
9529        """
9530        return _xapian.WritableDatabase_commit_transaction(self)
9531
9532
9533    def cancel_transaction(self):
9534        """
9535
9536
9537        Abort the transaction currently in progress, discarding the pending
9538        modifications made to the database.
9539
9540        void Xapian::WritableDatabase::cancel_transaction()
9541
9542        If an error occurs in this method, an exception will be thrown, but
9543        the transaction will be cancelled anyway.
9544
9545        Parameters:
9546        -----------
9547
9548        Xapian::DatabaseError:  will be thrown if a problem occurs while
9549        modifying the database.
9550
9551        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
9552        corrupt state.
9553
9554        Xapian::InvalidOperationError:  will be thrown if a transaction is not
9555        currently in progress.
9556
9557        Xapian::UnimplementedError:  will be thrown if transactions are not
9558        available for this database type.
9559        """
9560        return _xapian.WritableDatabase_cancel_transaction(self)
9561
9562
9563    def add_document(self, document):
9564        """
9565
9566
9567        Add a new document to the database.
9568
9569        Xapian::docid Xapian::WritableDatabase::add_document(const
9570        Xapian::Document &document)
9571
9572        This method adds the specified document to the database, returning a
9573        newly allocated document ID. Automatically allocated document IDs come
9574        from a per-database monotonically increasing counter, so IDs from
9575        deleted documents won't be reused.
9576
9577        If you want to specify the document ID to be used, you should call
9578        replace_document() instead.
9579
9580        Note that changes to the database won't be immediately committed to
9581        disk; see commit() for more details.
9582
9583        As with all database modification operations, the effect is atomic:
9584        the document will either be fully added, or the document fails to be
9585        added and an exception is thrown (possibly at a later time when
9586        commit() is called or the database is closed).
9587
9588        Parameters:
9589        -----------
9590
9591        document:  The new document to be added.
9592
9593        The document ID of the newly added document.
9594
9595        Parameters:
9596        -----------
9597
9598        Xapian::DatabaseError:  will be thrown if a problem occurs while
9599        writing to the database.
9600
9601        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
9602        corrupt state.
9603        """
9604        return _xapian.WritableDatabase_add_document(self, document)
9605
9606
9607    def delete_document(self, *args):
9608        """
9609
9610
9611        Delete any documents indexed by a term from the database.
9612
9613        void Xapian::WritableDatabase::delete_document(const std::string
9614        &unique_term)
9615
9616        This method removes any documents indexed by the specified term from
9617        the database.
9618
9619        A major use is for convenience when UIDs from another system are
9620        mapped to terms in Xapian, although this method has other uses (for
9621        example, you could add a "deletion date" term to documents at index
9622        time and use this method to delete all documents due for deletion on a
9623        particular date).
9624
9625        Parameters:
9626        -----------
9627
9628        unique_term:  The term to remove references to.
9629
9630        Parameters:
9631        -----------
9632
9633        Xapian::DatabaseError:  will be thrown if a problem occurs while
9634        writing to the database.
9635
9636        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
9637        corrupt state.
9638        """
9639        return _xapian.WritableDatabase_delete_document(self, *args)
9640
9641
9642    def replace_document(self, *args):
9643        """
9644
9645
9646        Replace any documents matching a term.
9647
9648        Xapian::docid Xapian::WritableDatabase::replace_document(const
9649        std::string &unique_term, const Xapian::Document &document)
9650
9651        This method replaces any documents indexed by the specified term with
9652        the specified document. If any documents are indexed by the term, the
9653        lowest document ID will be used for the document, otherwise a new
9654        document ID will be generated as for add_document.
9655
9656        One common use is to allow UIDs from another system to easily be
9657        mapped to terms in Xapian. Note that this method doesn't automatically
9658        add unique_term as a term, so you'll need to call
9659        document.add_term(unique_term) first when using replace_document() in
9660        this way.
9661
9662        Note that changes to the database won't be immediately committed to
9663        disk; see commit() for more details.
9664
9665        As with all database modification operations, the effect is atomic:
9666        the document(s) will either be fully replaced, or the document(s) fail
9667        to be replaced and an exception is thrown (possibly at a later time
9668        when commit() is called or the database is closed).
9669
9670        Parameters:
9671        -----------
9672
9673        unique_term:  The "unique" term.
9674
9675        document:  The new document.
9676
9677        The document ID that document was given.
9678
9679        Parameters:
9680        -----------
9681
9682        Xapian::DatabaseError:  will be thrown if a problem occurs while
9683        writing to the database.
9684
9685        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
9686        corrupt state.
9687        """
9688        return _xapian.WritableDatabase_replace_document(self, *args)
9689
9690
9691    def add_spelling(self, word, freqinc=1):
9692        """
9693
9694
9695        Add a word to the spelling dictionary.
9696
9697        void Xapian::WritableDatabase::add_spelling(const std::string &word,
9698        Xapian::termcount freqinc=1) const
9699
9700        If the word is already present, its frequency is increased.
9701
9702        Parameters:
9703        -----------
9704
9705        word:  The word to add.
9706
9707        freqinc:  How much to increase its frequency by (default 1).
9708        """
9709        return _xapian.WritableDatabase_add_spelling(self, word, freqinc)
9710
9711
9712    def remove_spelling(self, word, freqdec=1):
9713        """
9714
9715
9716        Remove a word from the spelling dictionary.
9717
9718        void Xapian::WritableDatabase::remove_spelling(const std::string
9719        &word, Xapian::termcount freqdec=1) const
9720
9721        The word's frequency is decreased, and if would become zero or less
9722        then the word is removed completely.
9723
9724        Parameters:
9725        -----------
9726
9727        word:  The word to remove.
9728
9729        freqdec:  How much to decrease its frequency by (default 1).
9730        """
9731        return _xapian.WritableDatabase_remove_spelling(self, word, freqdec)
9732
9733
9734    def add_synonym(self, term, synonym):
9735        """
9736
9737
9738        Add a synonym for a term.
9739
9740        void Xapian::WritableDatabase::add_synonym(const std::string &term,
9741        const std::string &synonym) const
9742
9743        Parameters:
9744        -----------
9745
9746        term:  The term to add a synonym for.
9747
9748        synonym:  The synonym to add. If this is already a synonym for term,
9749        then no action is taken.
9750        """
9751        return _xapian.WritableDatabase_add_synonym(self, term, synonym)
9752
9753
9754    def remove_synonym(self, term, synonym):
9755        """
9756
9757
9758        Remove a synonym for a term.
9759
9760        void Xapian::WritableDatabase::remove_synonym(const std::string &term,
9761        const std::string &synonym) const
9762
9763        Parameters:
9764        -----------
9765
9766        term:  The term to remove a synonym for.
9767
9768        synonym:  The synonym to remove. If this isn't currently a synonym for
9769        term, then no action is taken.
9770        """
9771        return _xapian.WritableDatabase_remove_synonym(self, term, synonym)
9772
9773
9774    def clear_synonyms(self, term):
9775        """
9776
9777
9778        Remove all synonyms for a term.
9779
9780        void Xapian::WritableDatabase::clear_synonyms(const std::string &term)
9781        const
9782
9783        Parameters:
9784        -----------
9785
9786        term:  The term to remove all synonyms for. If the term has no
9787        synonyms, no action is taken.
9788        """
9789        return _xapian.WritableDatabase_clear_synonyms(self, term)
9790
9791
9792    def set_metadata(self, key, metadata):
9793        """
9794
9795
9796        Set the user-specified metadata associated with a given key.
9797
9798        void Xapian::WritableDatabase::set_metadata(const std::string &key,
9799        const std::string &metadata)
9800
9801        This method sets the metadata value associated with a given key. If
9802        there is already a metadata value stored in the database with the same
9803        key, the old value is replaced. If you want to delete an existing item
9804        of metadata, just set its value to the empty string.
9805
9806        User-specified metadata allows you to store arbitrary information in
9807        the form of (key, value) pairs.
9808
9809        There's no hard limit on the number of metadata items, or the size of
9810        the metadata values. Metadata keys have a limited length, which depend
9811        on the backend. We recommend limiting them to 200 bytes. Empty keys
9812        are not valid, and specifying one will cause an exception.
9813
9814        Metadata modifications are committed to disk in the same way as
9815        modifications to the documents in the database are: i.e.,
9816        modifications are atomic, and won't be committed to disk immediately
9817        (see commit() for more details). This allows metadata to be used to
9818        link databases with versioned external resources by storing the
9819        appropriate version number in a metadata item.
9820
9821        You can also use the metadata to store arbitrary extra information
9822        associated with terms, documents, or postings by encoding the termname
9823        and/or document id into the metadata key.
9824
9825        Parameters:
9826        -----------
9827
9828        key:  The key of the metadata item to set.
9829
9830        metadata:  The value of the metadata item to set.
9831
9832        Parameters:
9833        -----------
9834
9835        Xapian::DatabaseError:  will be thrown if a problem occurs while
9836        writing to the database.
9837
9838        Xapian::DatabaseCorruptError:  will be thrown if the database is in a
9839        corrupt state.
9840
9841        Xapian::InvalidArgumentError:  will be thrown if the key supplied is
9842        empty.
9843
9844        Xapian::UnimplementedError:  will be thrown if the database backend in
9845        use doesn't support user- specified metadata.
9846        """
9847        return _xapian.WritableDatabase_set_metadata(self, key, metadata)
9848
9849WritableDatabase.commit = _xapian.SWIG_PyInstanceMethod_New(_xapian.WritableDatabase_commit)
9850WritableDatabase.flush = _xapian.SWIG_PyInstanceMethod_New(_xapian.WritableDatabase_flush)
9851WritableDatabase.begin_transaction = _xapian.SWIG_PyInstanceMethod_New(_xapian.WritableDatabase_begin_transaction)
9852WritableDatabase.commit_transaction = _xapian.SWIG_PyInstanceMethod_New(_xapian.WritableDatabase_commit_transaction)
9853WritableDatabase.cancel_transaction = _xapian.SWIG_PyInstanceMethod_New(_xapian.WritableDatabase_cancel_transaction)
9854WritableDatabase.add_document = _xapian.SWIG_PyInstanceMethod_New(_xapian.WritableDatabase_add_document)
9855WritableDatabase.delete_document = _xapian.SWIG_PyInstanceMethod_New(_xapian.WritableDatabase_delete_document)
9856WritableDatabase.replace_document = _xapian.SWIG_PyInstanceMethod_New(_xapian.WritableDatabase_replace_document)
9857WritableDatabase.add_spelling = _xapian.SWIG_PyInstanceMethod_New(_xapian.WritableDatabase_add_spelling)
9858WritableDatabase.remove_spelling = _xapian.SWIG_PyInstanceMethod_New(_xapian.WritableDatabase_remove_spelling)
9859WritableDatabase.add_synonym = _xapian.SWIG_PyInstanceMethod_New(_xapian.WritableDatabase_add_synonym)
9860WritableDatabase.remove_synonym = _xapian.SWIG_PyInstanceMethod_New(_xapian.WritableDatabase_remove_synonym)
9861WritableDatabase.clear_synonyms = _xapian.SWIG_PyInstanceMethod_New(_xapian.WritableDatabase_clear_synonyms)
9862WritableDatabase.set_metadata = _xapian.SWIG_PyInstanceMethod_New(_xapian.WritableDatabase_set_metadata)
9863WritableDatabase_swigregister = _xapian.WritableDatabase_swigregister
9864WritableDatabase_swigregister(WritableDatabase)
9865
9866
9867def remote_open(*args):
9868    """
9869
9870
9871    Construct a Database object for read-only access to a remote database
9872    accessed via a program.
9873
9874    Database Xapian::Remote::open(const std::string &program, const
9875    std::string &args, useconds_t timeout=10000)
9876
9877    Access to the remote database is done by running an external program
9878    and communicating with it on stdin/stdout.
9879
9880    Parameters:
9881    -----------
9882
9883    program:  the external program to run.
9884
9885    args:  space-separated list of arguments to pass to program.
9886
9887    timeout:  timeout in milliseconds. If this timeout is exceeded for any
9888    individual operation on the remote database then
9889    Xapian::NetworkTimeoutError is thrown. A timeout of 0 means don't
9890    timeout. (Default is 10000ms, which is 10 seconds).
9891    """
9892    return _xapian.remote_open(*args)
9893
9894def remote_open_writable(*args):
9895    """
9896
9897
9898    Construct a WritableDatabase object for update access to a remote
9899    database accessed via a program.
9900
9901    WritableDatabase Xapian::Remote::open_writable(const std::string
9902    &program, const std::string &args, useconds_t timeout=0, int flags=0)
9903
9904    Access to the remote database is done by running an external program
9905    and communicating with it on stdin/stdout.
9906
9907    Parameters:
9908    -----------
9909
9910    program:  the external program to run.
9911
9912    args:  space-separated list of arguments to pass to program.
9913
9914    timeout:  timeout in milliseconds. If this timeout is exceeded for any
9915    individual operation on the remote database then
9916    Xapian::NetworkTimeoutError is thrown. (Default is 0, which means
9917    don't timeout).
9918
9919    flags:   Xapian::DB_RETRY_LOCK or 0.
9920    """
9921    return _xapian.remote_open_writable(*args)
9922
9923
9924# Set the documentation format - this is used by tools like "epydoc" to decide
9925# how to format the documentation strings.
9926__docformat__ = "restructuredtext en"
9927
9928##################################
9929# Support for iteration of MSets #
9930##################################
9931
9932class MSetItem(object):
9933    """An item returned from iteration of the MSet.
9934
9935    The item supports access to the following attributes and properties:
9936
9937     - `docid`: The Xapian document ID corresponding to this MSet item.
9938     - `weight`: The weight corresponding to this MSet item.
9939     - `rank`: The rank of this MSet item.  The rank is the position in the
9940       total set of matching documents of this item.  The highest document is
9941       given a rank of 0.  If the MSet did not start at the highest matching
9942       document, because a non-zero 'start' parameter was supplied to
9943       get_mset(), the first document in the MSet will have a rank greater than
9944       0 (in fact, it will be equal to the value of 'start' supplied to
9945       get_mset()).
9946     - `percent`: The percentage score assigned to this MSet item.
9947     - `document`: The document for this MSet item.  This can be used to access
9948       the document data, or any other information stored in the document (such
9949       as term lists).  It is lazily evaluated.
9950     - `collapse_key`: The value of the key which was used for collapsing.
9951     - `collapse_count`: An estimate of the number of documents that have been
9952       collapsed into this one.
9953
9954    The collapse count estimate will always be less than or equal to the actual
9955    number of other documents satisfying the match criteria with the same
9956    collapse key as this document.  If may be 0 even though there are other
9957    documents with the same collapse key which satisfying the match criteria.
9958    However if this method returns non-zero, there definitely are other such
9959    documents.  So this method may be used to inform the user that there are
9960    "at least N other matches in this group", or to control whether to offer a
9961    "show other documents in this group" feature (but note that it may not
9962    offer it in every case where it would show other documents).
9963
9964    """
9965
9966    __slots__ = ('_mset', '_firstitem', 'docid', 'weight', 'rank',
9967                 'percent', 'collapse_key', 'collapse_count', '_document', )
9968
9969    def __init__(self, iter, mset):
9970        self._mset = mset
9971        self._firstitem = self._mset.get_firstitem()
9972        self.docid = iter.get_docid()
9973        self.weight = iter.get_weight()
9974        self.rank = iter.get_rank()
9975        self.percent = iter.get_percent()
9976        self.collapse_key = iter.get_collapse_key()
9977        self.collapse_count = iter.get_collapse_count()
9978        self._document = None
9979
9980    def _get_document(self):
9981        if self._document is None:
9982            self._document = self._mset._get_hit_internal(self.rank - self._firstitem).get_document()
9983        return self._document
9984
9985    document = property(_get_document, doc="The document object corresponding to this MSet item.")
9986
9987class MSetIter(object):
9988    """An iterator over the items in an MSet.
9989
9990    The iterator will return MSetItem objects, which will be evaluated lazily
9991    where appropriate.
9992
9993    """
9994    __slots__ = ('_iter', '_end', '_mset')
9995    def __init__(self, mset):
9996        self._iter = mset._begin()
9997        self._end = mset._end()
9998        self._mset = mset
9999
10000    def __iter__(self):
10001        return self
10002
10003    def __next__(self):
10004        if self._iter == self._end:
10005            raise StopIteration
10006        else:
10007            r = MSetItem(self._iter, self._mset)
10008            next(self._iter)
10009            return r
10010
10011# Modify the MSet to allow access to the python iterators, and have other
10012# convenience methods.
10013
10014def _mset_gen_iter(self):
10015    """Return an iterator over the MSet.
10016
10017    The iterator will return MSetItem objects, which will be evaluated lazily
10018    where appropriate.
10019
10020    """
10021    return MSetIter(self)
10022MSet.__iter__ = _mset_gen_iter
10023
10024MSet.__len__ = lambda self: MSet.size(self)
10025
10026def _mset_getitem(self, index):
10027    """Get an item from the MSet.
10028
10029    The supplied index is relative to the start of the MSet, not the absolute
10030    rank of the item.
10031
10032    Returns an MSetItem.
10033
10034    """
10035    if index < 0:
10036        index += len(self)
10037    if index < 0 or index >= len(self):
10038        raise IndexError("Mset index out of range")
10039    return MSetItem(self._get_hit_internal(index), self)
10040MSet.__getitem__ = _mset_getitem
10041MSet.get_hit = _mset_getitem
10042
10043
10044##################################
10045# Support for iteration of ESets #
10046##################################
10047
10048class ESetItem(object):
10049    """An item returned from iteration of the ESet.
10050
10051    The item supports access to the following attributes:
10052
10053     - `term`: The term corresponding to this ESet item.
10054     - `weight`: The weight corresponding to this ESet item.
10055
10056    """
10057    __slots__ = ('term', 'weight')
10058
10059    def __init__(self, iter):
10060        self.term = iter.get_term()
10061        self.weight = iter.get_weight()
10062
10063class ESetIter(object):
10064    """An iterator over the items in an ESet.
10065
10066    The iterator will return ESetItem objects.
10067
10068    """
10069    __slots__ = ('_iter', '_end')
10070    def __init__(self, eset):
10071        self._iter = eset._begin()
10072        self._end = eset._end()
10073
10074    def __iter__(self):
10075        return self
10076
10077    def __next__(self):
10078        if self._iter == self._end:
10079            raise StopIteration
10080        else:
10081            r = ESetItem(self._iter)
10082            next(self._iter)
10083            return r
10084
10085# Modify the ESet to allow access to the python iterators, and have other
10086# convenience methods.
10087
10088def _eset_gen_iter(self):
10089    """Return an iterator over the ESet.
10090
10091    The iterator will return ESetItem objects.
10092
10093    """
10094    return ESetIter(self)
10095ESet.__iter__ = _eset_gen_iter
10096
10097ESet.__len__ = lambda self: ESet.size(self)
10098
10099
10100#######################################
10101# Support for iteration of term lists #
10102#######################################
10103
10104class TermListItem(object):
10105    """An item returned from iteration of a term list.
10106
10107    The item supports access to the following attributes and properties:
10108
10109     - `term`: The term corresponding to this TermListItem.
10110     - `wdf`: The within document frequency of this term.
10111     - `termfreq`: The number of documents in the collection which are indexed
10112       by the term
10113     - `positer`: An iterator over the positions which the term appears at in
10114       the document.  This is only available until the iterator which returned
10115       this item next moves.
10116
10117    """
10118    __slots__ = ('_iter', 'term', '_wdf', '_termfreq')
10119
10120    def __init__(self, iter, term):
10121        self._iter = iter
10122        self.term = term
10123        self._wdf = None
10124        self._termfreq = None
10125
10126        if iter._has_wdf == TermIter.EAGER:
10127            self._wdf = iter._iter.get_wdf()
10128        if iter._has_termfreq == TermIter.EAGER:
10129            self._termfreq = iter._iter.get_termfreq()
10130
10131# Support for sequence API
10132        sequence = ['term', 'wdf', 'termfreq', 'positer']
10133        if iter._has_wdf == TermIter.INVALID:
10134            sequence[1] = 0
10135        if iter._has_termfreq == TermIter.INVALID:
10136            sequence[2] = 0
10137        if iter._has_positions == TermIter.INVALID:
10138            sequence[3] = PositionIter()
10139
10140    def _get_wdf(self):
10141        """Get the within-document-frequency of the current term.
10142
10143        This will raise a InvalidOperationError exception if the iterator this
10144        item came from doesn't support within-document-frequencies.
10145
10146        """
10147        if self._wdf is None:
10148            if self._iter._has_wdf == TermIter.INVALID:
10149                raise InvalidOperationError("Iterator does not support wdfs")
10150            if self.term is not self._iter._lastterm:
10151                raise InvalidOperationError("Iterator has moved, and does not support random access")
10152            self._wdf = self._iter._iter.get_wdf()
10153        return self._wdf
10154    wdf = property(_get_wdf, doc=
10155    """The within-document-frequency of the current term (if meaningful).
10156
10157    This will raise a InvalidOperationError exception if the iterator
10158    this item came from doesn't support within-document-frequencies.
10159
10160    """)
10161
10162    def _get_termfreq(self):
10163        """Get the term frequency.
10164
10165        This is the number of documents in the collection which are indexed by
10166        the term.
10167
10168        This will raise a InvalidOperationError exception if the iterator this
10169        item came from doesn't support term frequencies.
10170
10171        """
10172        if self._termfreq is None:
10173            if self._iter._has_termfreq == TermIter.INVALID:
10174                raise InvalidOperationError("Iterator does not support term frequencies")
10175            if self.term is not self._iter._lastterm:
10176                raise InvalidOperationError("Iterator has moved, and does not support random access")
10177            self._termfreq = self._iter._iter.get_termfreq()
10178        return self._termfreq
10179    termfreq = property(_get_termfreq, doc=
10180    """The term frequency of the current term (if meaningful).
10181
10182    This is the number of documents in the collection which are indexed by the
10183    term.
10184
10185    This will raise a InvalidOperationError exception if the iterator
10186    this item came from doesn't support term frequencies.
10187
10188    """)
10189
10190    def _get_positer(self):
10191        """Get a position list iterator.
10192
10193        The iterator will return integers representing the positions that the
10194        term occurs at.
10195
10196        This will raise a InvalidOperationError exception if the iterator this
10197        item came from doesn't support position lists, or if the iterator has
10198        moved on since the item was returned from it.
10199
10200        """
10201        if self._iter._has_positions == TermIter.INVALID:
10202            raise InvalidOperationError("Iterator does not support position lists")
10203# Access to position lists is always lazy, so we don't need to check
10204# _has_positions.
10205        if self.term is not self._iter._lastterm:
10206            raise InvalidOperationError("Iterator has moved, and does not support random access")
10207        return PositionIter(self._iter._iter._positionlist_begin(),
10208                            self._iter._iter._positionlist_end())
10209    positer = property(_get_positer, doc=
10210    """A position iterator for the current term (if meaningful).
10211
10212    The iterator will return integers representing the positions that the term
10213    occurs at.
10214
10215    This will raise a InvalidOperationError exception if the iterator this item
10216    came from doesn't support position lists, or if the iterator has moved on
10217    since the item was returned from it.
10218
10219    """)
10220
10221
10222class TermIter(object):
10223    """An iterator over a term list.
10224
10225    The iterator will return TermListItem objects, which will be evaluated
10226    lazily where appropriate.
10227
10228    """
10229    __slots__ = ('_iter', '_end', '_has_termfreq', '_has_wdf',
10230                 '_has_positions', '_return_strings', '_lastterm', '_moved')
10231
10232    INVALID = 0
10233    LAZY = 1
10234    EAGER = 2
10235
10236    def __init__(self, start, end, has_termfreq=INVALID,
10237                 has_wdf=INVALID, has_positions=INVALID,
10238                 return_strings=False):
10239        self._iter = start
10240        self._end = end
10241        self._has_termfreq = has_termfreq
10242        self._has_wdf = has_wdf
10243        self._has_positions = has_positions
10244        assert(has_positions != TermIter.EAGER) # Can't do eager access to position lists
10245        self._return_strings = return_strings
10246        self._lastterm = None # Used to test if the iterator has moved
10247
10248# _moved is True if we've moved onto the next item.  This is needed so
10249# that the iterator doesn't have to move on until just before next() is
10250# called: since the iterator starts by pointing at a valid item, we
10251# can't just call next(self._iter) unconditionally at the start of our
10252# __next__() method.
10253        self._moved = True
10254
10255    def __iter__(self):
10256        return self
10257
10258    def __next__(self):
10259        if not self._moved:
10260            next(self._iter)
10261            self._moved = True
10262
10263        if self._iter == self._end:
10264            self._lastterm = None
10265            raise StopIteration
10266        else:
10267            self._lastterm = self._iter.get_term()
10268            self._moved = False
10269            if self._return_strings:
10270                return self._lastterm
10271            return TermListItem(self, self._lastterm)
10272
10273    def skip_to(self, term):
10274        """Skip the iterator forward.
10275
10276        The iterator is advanced to the first term at or after the current
10277        position which is greater than or equal to the supplied term.
10278
10279        If there are no such items, this will raise StopIteration.
10280
10281        This returns the item which the iterator is moved to.  The subsequent
10282        item will be returned the next time that next() is called (unless
10283        skip_to() is called again first).
10284
10285        """
10286        if self._iter != self._end:
10287            self._iter.skip_to(term)
10288
10289        if self._iter == self._end:
10290            self._lastterm = None
10291            self._moved = True
10292            raise StopIteration
10293
10294# Update self._lastterm if the iterator has moved.
10295# TermListItems compare a saved value of lastterm with self._lastterm
10296# with the object identity comparator, so it is important to ensure
10297# that it does not get modified if the new term compares equal.
10298        newterm = self._iter.get_term()
10299        if newterm != self._lastterm:
10300            self._lastterm = newterm
10301
10302        self._moved = False
10303        if self._return_strings:
10304            return self._lastterm
10305        return TermListItem(self, self._lastterm)
10306
10307# Modify Enquire to add a "matching_terms()" method.
10308def _enquire_gen_iter(self, which):
10309    """Get an iterator over the terms which match a given match set item.
10310
10311    The match set item to consider is specified by the `which` parameter, which
10312    may be a document ID, or an MSetItem object.
10313
10314    The iterator will return string objects.
10315
10316    """
10317    if isinstance(which, MSetItem):
10318        which = which.docid
10319    return TermIter(self._get_matching_terms_begin(which),
10320                    self._get_matching_terms_end(which),
10321                    return_strings=True)
10322Enquire.matching_terms = _enquire_gen_iter
10323
10324# Modify Query to add an "__iter__()" method.
10325def _query_gen_iter(self):
10326    """Get an iterator over the terms in a query.
10327
10328    The iterator will return string objects.
10329
10330    """
10331    return TermIter(self._get_terms_begin(),
10332                    self._get_terms_end(),
10333                    return_strings=True)
10334Query.__iter__ = _query_gen_iter
10335
10336# Modify Database to add an "__iter__()" method and an "allterms()" method.
10337def _database_gen_allterms_iter(self, prefix=None):
10338    """Get an iterator over all the terms in the database.
10339
10340    The iterator will return TermListItem objects, but these will not support
10341    access to wdf, or position information.
10342
10343    Access to term frequency information is only available until the iterator
10344    has moved on.
10345
10346    If prefix is supplied, only terms which start with that prefix will be
10347    returned.
10348
10349    """
10350    if prefix is None:
10351        return TermIter(self._allterms_begin(), self._allterms_end(),
10352                        has_termfreq=TermIter.LAZY)
10353    else:
10354        return TermIter(self._allterms_begin(prefix), self._allterms_end(prefix),
10355                        has_termfreq=TermIter.LAZY)
10356Database.__iter__ = _database_gen_allterms_iter
10357Database.allterms = _database_gen_allterms_iter
10358
10359# Modify Database to add a "termlist()" method.
10360def _database_gen_termlist_iter(self, docid):
10361    """Get an iterator over all the terms which index a given document ID.
10362
10363    The iterator will return TermListItem objects.
10364
10365    Access to term frequency and position information is only available until
10366    the iterator has moved on.
10367
10368    """
10369# Note: has_termfreq is set to LAZY because most databases don't store term
10370# frequencies in the termlist (because this would require updating many termlist
10371# entries for every document update), so access to the term frequency requires a
10372# separate lookup.
10373    return TermIter(self._termlist_begin(docid), self._termlist_end(docid),
10374                    has_termfreq=TermIter.LAZY,
10375                    has_wdf=TermIter.EAGER,
10376                    has_positions=TermIter.LAZY)
10377Database.termlist = _database_gen_termlist_iter
10378
10379# Modify Database to add a "spellings()" method.
10380def _database_gen_spellings_iter(self):
10381    """Get an iterator which returns all the spelling correction targets
10382
10383    The iterator will return TermListItem objects.  Only the term frequency is
10384    available; wdf and positions are not meaningful.
10385
10386    """
10387    return TermIter(self._spellings_begin(), self._spellings_end(),
10388                    has_termfreq=TermIter.EAGER,
10389                    has_wdf=TermIter.INVALID,
10390                    has_positions=TermIter.INVALID)
10391Database.spellings = _database_gen_spellings_iter
10392
10393# Modify Database to add a "synonyms()" method.
10394def _database_gen_synonyms_iter(self, term):
10395    """Get an iterator which returns all the synonyms for a given term.
10396
10397    The term to return synonyms for is specified by the `term` parameter.
10398
10399    The iterator will return string objects.
10400
10401    """
10402    return TermIter(self._synonyms_begin(term),
10403                    self._synonyms_end(term),
10404                    return_strings=True)
10405Database.synonyms = _database_gen_synonyms_iter
10406
10407# Modify Database to add a "synonym_keys()" method.
10408def _database_gen_synonym_keys_iter(self, prefix=""):
10409    """Get an iterator which returns all the terms which have synonyms.
10410
10411    The iterator will return string objects.
10412
10413    If `prefix` is non-empty, only terms with this prefix are returned.
10414
10415    """
10416    return TermIter(self._synonym_keys_begin(prefix),
10417                    self._synonym_keys_end(prefix),
10418                    return_strings=True)
10419Database.synonym_keys = _database_gen_synonym_keys_iter
10420
10421# Modify Database to add a "metadata_keys()" method, instead of direct access
10422# to metadata_keys_begin and metadata_keys_end.
10423def _database_gen_metadata_keys_iter(self, prefix=""):
10424    """Get an iterator which returns all the metadata keys.
10425
10426    The iterator will return string objects.
10427
10428    If `prefix` is non-empty, only metadata keys with this prefix are returned.
10429
10430    """
10431    return TermIter(self._metadata_keys_begin(prefix),
10432                    self._metadata_keys_end(prefix),
10433                    return_strings=True)
10434Database.metadata_keys = _database_gen_metadata_keys_iter
10435
10436# Modify Document to add an "__iter__()" method and a "termlist()" method.
10437def _document_gen_termlist_iter(self):
10438    """Get an iterator over all the terms in a document.
10439
10440    The iterator will return TermListItem objects.
10441
10442    Access to term frequency and position information is only available until
10443    the iterator has moved on.
10444
10445    Note that term frequency information is only meaningful for a document
10446    retrieved from a database.  If term frequency information is requested for
10447    a document which was freshly created, an InvalidOperationError will be
10448    raised.
10449
10450    """
10451# Note: document termlist iterators may be implemented entirely in-memory
10452# (in which case access to all items could be allowed eagerly), but may
10453# also be implemented by returning a database termlist (for documents which
10454# are stored in a database, rather than freshly created).  We choose the
10455# most conservative settings, to avoid doing eager access when lazy access
10456# would be more appropriate.
10457    return TermIter(self._termlist_begin(), self._termlist_end(),
10458                    has_termfreq=TermIter.LAZY,
10459                    has_wdf=TermIter.EAGER,
10460                    has_positions=TermIter.LAZY)
10461Document.__iter__ = _document_gen_termlist_iter
10462Document.termlist = _document_gen_termlist_iter
10463
10464# Modify QueryParser to add a "stoplist()" method.
10465def _queryparser_gen_stoplist_iter(self):
10466    """Get an iterator over all the stopped terms from the previous query.
10467
10468    This returns an iterator over all the terms which were omitted from the
10469    previously parsed query due to being considered to be stopwords.  Each
10470    instance of a word omitted from the query is represented in the returned
10471    list, in the order in which the
10472
10473    The iterator will return string objects.
10474
10475    """
10476    return TermIter(self._stoplist_begin(), self._stoplist_end(),
10477                    return_strings=True)
10478QueryParser.stoplist = _queryparser_gen_stoplist_iter
10479
10480# Modify QueryParser to add an "unstemlist()" method.
10481def _queryparser_gen_unstemlist_iter(self, tname):
10482    """Get an iterator over all the unstemmed forms of a stemmed term.
10483
10484    This returns an iterator which returns all the unstemmed words which were
10485    stemmed to the stemmed form specified by `tname` when parsing the previous
10486    query.  Each instance of a word which stems to `tname` is returned by the
10487    iterator in the order in which the words appeared in the query - an
10488    individual unstemmed word may thus occur multiple times.
10489
10490    The iterator will return string objects.
10491
10492    """
10493    return TermIter(self._unstem_begin(tname), self._unstem_end(tname),
10494                    return_strings=True)
10495QueryParser.unstemlist = _queryparser_gen_unstemlist_iter
10496
10497# Modify ValueCountMatchSpy to add an "values()" method.
10498def wrapper():
10499    begin = ValueCountMatchSpy.values_begin
10500    del ValueCountMatchSpy.values_begin
10501    end = ValueCountMatchSpy.values_end
10502    del ValueCountMatchSpy.values_end
10503    def values(self):
10504        """Get an iterator over all the values in the slot.
10505
10506        Values will be returned in ascending alphabetical order.
10507
10508        The iterator will return TermListItem objects: the value can be
10509        accessed as the `term` property, and the frequency can be accessed as
10510        the `termfreq` property.
10511
10512        """
10513        return TermIter(begin(self), end(self), has_termfreq=TermIter.EAGER)
10514    return values
10515ValueCountMatchSpy.values = wrapper()
10516del wrapper
10517
10518# Modify ValueCountMatchSpy to add an "top_values()" method.
10519def wrapper():
10520    begin = ValueCountMatchSpy.top_values_begin
10521    del ValueCountMatchSpy.top_values_begin
10522    end = ValueCountMatchSpy.top_values_end
10523    del ValueCountMatchSpy.top_values_end
10524    def top_values(self, maxvalues):
10525        """Get an iterator over the most frequent values for the slot.
10526
10527        Values will be returned in descending order of frequency.  Values with
10528        the same frequency will be returned in ascending alphabetical order.
10529
10530        The iterator will return TermListItem objects: the value can be
10531        accessed as the `term` property, and the frequency can be accessed as
10532        the `termfreq` property.
10533
10534        """
10535        return TermIter(begin(self, maxvalues), end(self, maxvalues),
10536                        has_termfreq=TermIter.EAGER)
10537    return top_values
10538ValueCountMatchSpy.top_values = wrapper()
10539del wrapper
10540
10541# When we make a query, keep a note of postingsources involved, so they won't
10542# be deleted. This hack can probably be removed once xapian bug #186 is fixed.
10543__query_init_orig = Query.__init__
10544def _query_init(self, *args):
10545    """Make a new query object.
10546
10547    Many possible arguments are possible - see the documentation for details.
10548
10549    """
10550    ps = []
10551    if len(args) == 1 and isinstance(args[0], PostingSource):
10552        ps.append(args[0])
10553    else:
10554        for arg in args:
10555            if isinstance(arg, Query):
10556                ps.extend(getattr(arg, '_ps', []))
10557            elif hasattr(arg, '__iter__'):
10558                for listarg in arg:
10559                    if isinstance(listarg, Query):
10560                        ps.extend(getattr(listarg, '_ps', []))
10561    __query_init_orig(self, *args)
10562    self._ps = ps
10563Query.__init__ = _query_init
10564del _query_init
10565
10566# When setting a query on enquire, keep a note of postingsources involved, so
10567# they won't be deleted. This hack can probably be removed once xapian bug #186
10568# is fixed.
10569__enquire_set_query_orig = Enquire.set_query
10570def _enquire_set_query(self, query, qlen=0):
10571    self._ps = getattr(query, '_ps', [])
10572    return __enquire_set_query_orig(self, query, qlen)
10573_enquire_set_query.__doc__ = __enquire_set_query_orig.__doc__
10574Enquire.set_query = _enquire_set_query
10575del _enquire_set_query
10576
10577# When getting  a query from enquire, keep a note of postingsources involved,
10578# so they won't be deleted. This hack can probably be removed once xapian bug
10579# #186 is fixed.
10580__enquire_get_query_orig = Enquire.get_query
10581def _enquire_get_query(self):
10582    query = __enquire_get_query_orig(self)
10583    query._ps = getattr(self, '_ps', [])
10584    return query
10585_enquire_get_query.__doc__ = __enquire_get_query_orig.__doc__
10586Enquire.get_query = _enquire_get_query
10587del _enquire_get_query
10588
10589# When we set a ValueRangeProcessor into the QueryParser, keep a python
10590# reference so it won't be deleted. This hack can probably be removed once
10591# xapian bug #186 is fixed.
10592__queryparser_add_valuerangeprocessor_orig = QueryParser.add_valuerangeprocessor
10593def _queryparser_add_valuerangeprocessor(self, vrproc):
10594    if not hasattr(self, '_vrps'):
10595        self._vrps = []
10596    self._vrps.append(vrproc)
10597    return __queryparser_add_valuerangeprocessor_orig(self, vrproc)
10598_queryparser_add_valuerangeprocessor.__doc__ = __queryparser_add_valuerangeprocessor_orig.__doc__
10599QueryParser.add_valuerangeprocessor = _queryparser_add_valuerangeprocessor
10600del _queryparser_add_valuerangeprocessor
10601
10602# When we set a RangeProcessor into the QueryParser, keep a python
10603# reference so it won't be deleted. This hack can probably be removed once
10604# xapian bug #186 is fixed.
10605__queryparser_add_rangeprocessor_orig = QueryParser.add_rangeprocessor
10606def _queryparser_add_rangeprocessor(self, rproc):
10607    if not hasattr(self, '_rps'):
10608        self._rps = []
10609    self._rps.append(rproc)
10610    return __queryparser_add_rangeprocessor_orig(self, rproc)
10611_queryparser_add_rangeprocessor.__doc__ = __queryparser_add_rangeprocessor_orig.__doc__
10612QueryParser.add_rangeprocessor = _queryparser_add_rangeprocessor
10613del _queryparser_add_rangeprocessor
10614
10615# When we set a FieldProcessor into the QueryParser, keep a python
10616# reference so it won't be deleted. This hack can probably be removed once
10617# xapian bug #186 is fixed.
10618__queryparser_add_prefix_orig = QueryParser.add_prefix
10619def _queryparser_add_prefix(self, s, proc):
10620    if not isinstance(proc, (str, bytes)):
10621        if not hasattr(self, '_fps'):
10622            self._fps = []
10623        self._fps.append(proc)
10624    return __queryparser_add_prefix_orig(self, s, proc)
10625_queryparser_add_prefix.__doc__ = __queryparser_add_prefix_orig.__doc__
10626QueryParser.add_prefix = _queryparser_add_prefix
10627del _queryparser_add_prefix
10628__queryparser_add_boolean_prefix_orig = QueryParser.add_boolean_prefix
10629def _queryparser_add_boolean_prefix(self, s, proc, exclusive = True):
10630    if not isinstance(proc, (str, bytes)):
10631        if not hasattr(self, '_fps'):
10632            self._fps = []
10633        self._fps.append(proc)
10634    return __queryparser_add_boolean_prefix_orig(self, s, proc, exclusive)
10635_queryparser_add_boolean_prefix.__doc__ = __queryparser_add_boolean_prefix_orig.__doc__
10636QueryParser.add_boolean_prefix = _queryparser_add_boolean_prefix
10637del _queryparser_add_boolean_prefix
10638
10639# When we set a Stopper into the QueryParser, keep a python reference so it
10640# won't be deleted. This hack can probably be removed once xapian bug #186 is
10641# fixed.
10642__queryparser_set_stopper_orig = QueryParser.set_stopper
10643def _queryparser_set_stopper(self, stopper):
10644    self._stopper = stopper
10645    return __queryparser_set_stopper_orig(self, stopper)
10646_queryparser_set_stopper.__doc__ = __queryparser_set_stopper_orig.__doc__
10647QueryParser.set_stopper = _queryparser_set_stopper
10648del _queryparser_set_stopper
10649
10650# When we set a Stopper into the TermGenerator, keep a python reference so it
10651# won't be deleted. This hack can probably be removed once xapian bug #186 is
10652# fixed.
10653__termgenerator_set_stopper_orig = TermGenerator.set_stopper
10654def _termgenerator_set_stopper(self, stopper):
10655    self._stopper = stopper
10656    return __termgenerator_set_stopper_orig(self, stopper)
10657_termgenerator_set_stopper.__doc__ = __termgenerator_set_stopper_orig.__doc__
10658TermGenerator.set_stopper = _termgenerator_set_stopper
10659del _termgenerator_set_stopper
10660
10661# When we set a Sorter on enquire, keep a python reference so it won't be
10662# deleted.  This hack can probably be removed once xapian bug #186 is fixed.
10663__enquire_set_sort_by_key_orig = Enquire.set_sort_by_key
10664def _enquire_set_sort_by_key(self, sorter, reverse):
10665    self._sorter = sorter
10666    return __enquire_set_sort_by_key_orig(self, sorter, reverse)
10667_enquire_set_sort_by_key.__doc__ = __enquire_set_sort_by_key_orig.__doc__
10668Enquire.set_sort_by_key = _enquire_set_sort_by_key
10669del _enquire_set_sort_by_key
10670
10671__enquire_set_sort_by_key_then_relevance_orig = Enquire.set_sort_by_key_then_relevance
10672def _enquire_set_sort_by_key_then_relevance(self, sorter, reverse):
10673    self._sorter = sorter
10674    return __enquire_set_sort_by_key_then_relevance_orig(self, sorter, reverse)
10675_enquire_set_sort_by_key_then_relevance.__doc__ = __enquire_set_sort_by_key_then_relevance_orig.__doc__
10676Enquire.set_sort_by_key_then_relevance = _enquire_set_sort_by_key_then_relevance
10677del _enquire_set_sort_by_key_then_relevance
10678
10679__enquire_set_sort_by_relevance_then_key_orig = Enquire.set_sort_by_relevance_then_key
10680def _enquire_set_sort_by_relevance_then_key(self, sorter, reverse):
10681    self._sorter = sorter
10682    return __enquire_set_sort_by_relevance_then_key_orig(self, sorter, reverse)
10683_enquire_set_sort_by_relevance_then_key.__doc__ = __enquire_set_sort_by_relevance_then_key_orig.__doc__
10684Enquire.set_sort_by_relevance_then_key = _enquire_set_sort_by_relevance_then_key
10685del _enquire_set_sort_by_relevance_then_key
10686
10687
10688##########################################
10689# Support for iteration of posting lists #
10690##########################################
10691
10692class PostingItem(object):
10693    """An item returned from iteration of a posting list.
10694
10695    The item supports access to the following attributes and properties:
10696
10697     - `docid`: The document ID corresponding to this PostingItem.
10698     - `doclength`: The length of the document corresponding to this
10699       PostingItem.
10700     - `wdf`: The within document frequency of the term which the posting list
10701       is for in the document corresponding to this PostingItem.
10702     - `positer`: An iterator over the positions which the term corresponing to
10703       this posting list occurs at in the document corresponding to this
10704       PostingItem.  This is only available until the iterator which returned
10705       this item next moves.
10706
10707    """
10708    __slots__ = ('_iter', 'docid', 'doclength', 'wdf',)
10709
10710    def __init__(self, iter):
10711        self._iter = iter
10712        self.docid = iter._iter.get_docid()
10713        self.doclength = iter._iter.get_doclength()
10714        self.wdf = iter._iter.get_wdf()
10715
10716# Support for sequence API
10717        sequence = ['docid', 'doclength', 'wdf', 'positer']
10718        if not iter._has_positions:
10719            sequence[3] = PositionIter()
10720
10721    def _get_positer(self):
10722        """Get a position list iterator.
10723
10724        The iterator will return integers representing the positions that the
10725        term occurs at in the document corresponding to this PostingItem.
10726
10727        This will raise a InvalidOperationError exception if the iterator this
10728        item came from doesn't support position lists, or if the iterator has
10729        moved on since the item was returned from it.
10730
10731        """
10732        if not self._iter._has_positions:
10733            raise InvalidOperationError("Iterator does not support position lists")
10734        if self._iter._iter == self._iter._end or \
10735           self.docid != self._iter._iter.get_docid():
10736            raise InvalidOperationError("Iterator has moved, and does not support random access")
10737        return PositionIter(self._iter._iter._positionlist_begin(),
10738                            self._iter._iter._positionlist_end())
10739    positer = property(_get_positer, doc=
10740    """A position iterator for the current posting (if meaningful).
10741
10742    The iterator will return integers representing the positions that the term
10743    occurs at.
10744
10745    This will raise a InvalidOperationError exception if the iterator this item
10746    came from doesn't support position lists, or if the iterator has moved on
10747    since the item was returned from it.
10748
10749    """)
10750
10751
10752class PostingIter(object):
10753    """An iterator over a posting list.
10754
10755    The iterator will return PostingItem objects, which will be evaluated
10756    lazily where appropriate.
10757
10758    """
10759    __slots__ = ('_iter', '_end', '_has_positions', '_moved')
10760
10761    def __init__(self, start, end, has_positions=False):
10762        self._iter = start
10763        self._end = end
10764        self._has_positions = has_positions
10765
10766# _moved is True if we've moved onto the next item.  This is needed so
10767# that the iterator doesn't have to move on until just before next() is
10768# called: since the iterator starts by pointing at a valid item, we
10769# can't just call next(self._iter) unconditionally at the start of our
10770# __next__() method.
10771        self._moved = True
10772
10773    def __iter__(self):
10774        return self
10775
10776    def __next__(self):
10777        if not self._moved:
10778            next(self._iter)
10779            self._moved = True
10780
10781        if self._iter == self._end:
10782            raise StopIteration
10783        else:
10784            self._moved = False
10785            return PostingItem(self)
10786
10787    def skip_to(self, docid):
10788        """Skip the iterator forward.
10789
10790        The iterator is advanced to the first document with a document ID
10791        which is greater than or equal to the supplied document ID.
10792
10793        If there are no such items, this will raise StopIteration.
10794
10795        This returns the item which the iterator is moved to.  The subsequent
10796        item will be returned the next time that next() is called (unless
10797        skip_to() is called again first).
10798
10799        """
10800        if self._iter != self._end:
10801            self._iter.skip_to(docid)
10802        if self._iter == self._end:
10803            self._moved = True
10804            raise StopIteration
10805        self._moved = False
10806        return PostingItem(self)
10807
10808def _database_gen_postlist_iter(self, tname):
10809    """Get an iterator over the postings which are indexed by a given term.
10810
10811    If `tname` is empty, an iterator over all the documents will be returned
10812    (this will contain one entry for each document, will always return a wdf of
10813    1, and will not allow access to a position iterator).
10814
10815    """
10816    if len(tname) != 0:
10817        return PostingIter(self._postlist_begin(tname), self._postlist_end(tname),
10818                           has_positions=True)
10819    else:
10820        return PostingIter(self._postlist_begin(tname), self._postlist_end(tname))
10821Database.postlist = _database_gen_postlist_iter
10822
10823
10824###########################################
10825# Support for iteration of position lists #
10826###########################################
10827
10828class PositionIter(object):
10829    """An iterator over a position list.
10830
10831    The iterator will return integers, in ascending order.
10832
10833    """
10834    def __init__(self, start = 0, end = 0):
10835        self.iter = start
10836        self.end = end
10837
10838    def __iter__(self):
10839        return self
10840
10841    def __next__(self):
10842        if self.iter==self.end:
10843            raise StopIteration
10844        else:
10845            r = self.iter.get_termpos()
10846            next(self.iter)
10847            return r
10848
10849# Modify Database to add a "positionlist()" method.
10850def _database_gen_positionlist_iter(self, docid, tname):
10851    """Get an iterator over all the positions in a given document of a term.
10852
10853    The iterator will return integers, in ascending order.
10854
10855    """
10856    return PositionIter(self._positionlist_begin(docid, tname), self._positionlist_end(docid, tname))
10857Database.positionlist = _database_gen_positionlist_iter
10858
10859########################################
10860# Support for iteration of value lists #
10861########################################
10862
10863class ValueItem(object):
10864    """An item returned from iteration of the values in a document.
10865
10866    The item supports access to the following attributes:
10867
10868     - `num`: The number of the value.
10869     - `value`: The contents of the value.
10870
10871    """
10872
10873    __slots__ = ('num', 'value', )
10874
10875    def __init__(self, num, value):
10876        self.num = num
10877        self.value = value
10878
10879class ValueIter(object):
10880    """An iterator over all the values stored in a document.
10881
10882    The iterator will return ValueItem objects, in ascending order of value number.
10883
10884    """
10885    def __init__(self, start, end):
10886        self.iter = start
10887        self.end = end
10888
10889    def __iter__(self):
10890        return self
10891
10892    def __next__(self):
10893        if self.iter==self.end:
10894            raise StopIteration
10895        else:
10896            r = ValueItem(self.iter.get_valueno(), self.iter.get_value())
10897            next(self.iter)
10898            return r
10899
10900# Modify Document to add a "values()" method.
10901def _document_gen_values_iter(self):
10902    """Get an iterator over all the values stored in a document.
10903
10904    The iterator will return ValueItem objects, in ascending order of value number.
10905
10906    """
10907    return ValueIter(self._values_begin(), self._values_end())
10908Document.values = _document_gen_values_iter
10909
10910
10911##########################################
10912# Support for iteration of value streams #
10913##########################################
10914
10915class ValueStreamItem(object):
10916    """An item returned from iteration of the values in a document.
10917
10918    The item supports access to the following attributes:
10919
10920     - `docid`: The docid for the item.
10921     - `value`: The contents of the value.
10922
10923    """
10924
10925    __slots__ = ('docid', 'value', )
10926
10927    def __init__(self, docid, value):
10928        self.docid = docid
10929        self.value = value
10930
10931class ValueStreamIter(object):
10932    """An iterator over all the values stored in a document.
10933
10934    The iterator will return ValueStreamItem objects, in ascending order of value number.
10935
10936    """
10937    def __init__(self, start, end):
10938        self.iter = start
10939        self.end = end
10940        self.moved = True
10941
10942    def __iter__(self):
10943        return self
10944
10945    def __next__(self):
10946        if not self.moved:
10947            self.iter.__next__()
10948            self.moved = True
10949
10950        if self.iter==self.end:
10951            raise StopIteration
10952        else:
10953            self.moved = False
10954            return ValueStreamItem(self.iter.get_docid(), self.iter.get_value())
10955
10956    def skip_to(self, docid):
10957        """Skip the iterator forward.
10958
10959        The iterator is advanced to the first document with a document ID
10960        which is greater than or equal to the supplied document ID.
10961
10962        If there are no such items, this will raise StopIteration.
10963
10964        This returns the item which the iterator is moved to.  The subsequent
10965        item will be returned the next time that next() is called (unless
10966        skip_to() is called again first).
10967
10968        """
10969        if self.iter != self.end:
10970            self.iter.skip_to(docid)
10971        if self.iter == self.end:
10972            self.moved = True
10973            raise StopIteration
10974        self.moved = False
10975        return ValueStreamItem(self.iter.get_docid(), self.iter.get_value())
10976
10977# Modify Database to add a "valuestream()" method, and remove the
10978# valuestream_begin() and valuestream_end() methods.
10979def wrapper():
10980    vs_begin = Database.valuestream_begin
10981    del Database.valuestream_begin
10982    vs_end = Database.valuestream_end
10983    del Database.valuestream_end
10984    def valuestream(self, slot):
10985        """Get an iterator over all the values stored in a slot in the database.
10986
10987        The iterator will return ValueStreamItem objects, in ascending order of
10988        document id.
10989
10990        """
10991        return ValueStreamIter(vs_begin(self, slot), vs_end(self, slot))
10992    return valuestream
10993Database.valuestream = wrapper()
10994del wrapper
10995
10996##########################################
10997# Support for iteration of LatLongCoords #
10998##########################################
10999
11000class LatLongCoordsIter(object):
11001    """An iterator over all the coordinates in a LatLongCoords object.
11002
11003    The iterator returns LatLongCoord objects.
11004
11005    """
11006    def __init__(self, start, end):
11007        self.iter = start
11008        self.end = end
11009
11010    def __iter__(self):
11011        return self
11012
11013    def __eq__(self, other):
11014        return self.equals(other)
11015
11016    def __ne__(self, other):
11017        return not self.equals(other)
11018
11019    def __next__(self):
11020        if self.iter.equals(self.end):
11021            raise StopIteration
11022        else:
11023            r = self.iter.get_coord()
11024            self.iter.__next__()
11025            return r
11026
11027# Modify LatLongCoords to make it iterable.
11028def _latlongcoords_iter(self):
11029    """Get an iterator over all the coordinates in a LatLongCoords.
11030
11031    The iterator will return xapian.LatLongCoord objects.
11032
11033    """
11034    return LatLongCoordsIter(self.begin(), self.end())
11035LatLongCoords.__iter__ = _latlongcoords_iter
11036del _latlongcoords_iter
11037del LatLongCoordsIterator
11038
11039# Fix up Enquire so that it keeps a python reference to the deciders supplied
11040# to it so that they won't be deleted before the Enquire object.  This hack can
11041# probably be removed once xapian bug #186 is fixed.
11042_enquire_add_matchspy_orig = Enquire.add_matchspy
11043def _enquire_match_spy_add(self, decider):
11044    if not hasattr(self, '_deciders'):
11045        self._deciders = []
11046    self._deciders.append(decider)
11047    _enquire_add_matchspy_orig(self, decider)
11048_enquire_match_spy_add.__doc__ = Enquire.add_matchspy.__doc__
11049Enquire.add_matchspy = _enquire_match_spy_add
11050
11051_enquire_clear_matchspies_orig = Enquire.clear_matchspies
11052def _enquire_match_spies_clear(self):
11053    _enquire_clear_matchspies_orig(self)
11054    if hasattr(self, '_deciders'):
11055        del self._deciders
11056_enquire_match_spies_clear.__doc__ = Enquire.clear_matchspies.__doc__
11057Enquire.clear_matchspies = _enquire_match_spies_clear
11058
11059
11060# Fix up Stem.__init__() so that it calls __disown__() on the passed
11061# StemImplementation object so that Python won't delete it from under us.
11062_stem_init_orig = Stem.__init__
11063def _stem_init(self, *args):
11064    _stem_init_orig(self, *args)
11065    if len(args) > 0 and isinstance(args[0], StemImplementation):
11066        args[0].__disown__()
11067_stem_init.__doc__ = Stem.__init__.__doc__
11068Stem.__init__ = _stem_init
11069
11070
11071# Remove static methods which shouldn't be in the API.
11072del Document_unserialise
11073del Query_unserialise
11074del Stem_get_available_languages
11075
11076# Add wrappers for Query::MatchAll and Query::MatchNothing
11077Query.MatchAll = Query("")
11078Query.MatchNothing = Query()
11079
11080
11081# Set the list of names which should be public.
11082# Note that this needs to happen at the end of xapian.py.
11083__all__ = []
11084for item in dir():
11085    if item.startswith('_') or item.endswith('_swigregister') or item.endswith('Iterator'):
11086        continue
11087    __all__.append(item)
11088__all__ = tuple(__all__)
11089
11090
11091
11092