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