This file is indexed.

/usr/share/doc/python-xapian/html/introduction.html is in python-xapian 1.4.5-1ubuntu3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Introduction &#8212; Xapian Python Bindings 1.4.5 documentation</title>
    <link rel="stylesheet" href="_static/classic.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '1.4.5',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true,
        SOURCELINK_SUFFIX: '.txt'
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Examples" href="examples.html" />
    <link rel="prev" title="Welcome to Xapian Python Bindings’s documentation!" href="index.html" /> 
  </head>
  <body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="examples.html" title="Examples"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="index.html" title="Welcome to Xapian Python Bindings’s documentation!"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">Xapian Python Bindings 1.4.5 documentation</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="introduction">
<h1>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline"></a></h1>
<p>The Python bindings for Xapian are packaged in the <code class="docutils literal"><span class="pre">xapian</span></code> module,
and largely follow the C++ API, with the following differences and
additions. Python strings and lists, etc., are converted automatically
in the bindings, so generally it should just work as expected.</p>
<p>The <code class="docutils literal"><span class="pre">examples</span></code> subdirectory contains examples showing how to use the
Python bindings based on the simple examples from <code class="docutils literal"><span class="pre">xapian-examples</span></code>:
<a class="reference internal" href="examples.html#simpleindex"><span class="std std-ref">simpleindex.py</span></a>,
<a class="reference internal" href="examples.html#simplesearch"><span class="std std-ref">simplesearch.py</span></a>,
<a class="reference internal" href="examples.html#simpleexpand"><span class="std std-ref">simpleexpand.py</span></a>,
There’s also
<a class="reference internal" href="examples.html#simplematchdecider"><span class="std std-ref">simplematchdecider.py</span></a>,
which shows how to define a MatchDecider in Python.</p>
<p>The Python bindings come with a test suite, consisting of two test files:
<code class="docutils literal"><span class="pre">smoketest.py</span></code> and <code class="docutils literal"><span class="pre">pythontest.py</span></code>. These are run by the
“<code class="docutils literal"><span class="pre">make</span> <span class="pre">check</span></code>” command, or may be run manually.  By default, they
will display the names of any tests which failed, and then display a count of
tests which run and which failed.  The verbosity may be increased by setting
the “<code class="docutils literal"><span class="pre">VERBOSE</span></code>” environment variable: a value of 1 will display
detailed information about failures, and a value of 2 will display further
information about the progress of tests.</p>
<div class="section" id="exceptions">
<h2>Exceptions<a class="headerlink" href="#exceptions" title="Permalink to this headline"></a></h2>
<p>Xapian exceptions are translated into Python exceptions with the same names
and inheritance hierarchy as the C++ exception classes.  The base class of
all Xapian exceptions is the <code class="docutils literal"><span class="pre">xapian.Error</span></code> class, and this in
turn is a child of the standard python <code class="docutils literal"><span class="pre">exceptions.Exception</span></code>
class.</p>
<p>This means that programs can trap all xapian exceptions using “<code class="docutils literal"><span class="pre">except</span>
<span class="pre">xapian.Error</span></code>”, and can trap all exceptions which don’t indicate that
the program should terminate using “<code class="docutils literal"><span class="pre">except</span> <span class="pre">Exception</span></code>”.</p>
</div>
<div class="section" id="unicode">
<h2>Unicode<a class="headerlink" href="#unicode" title="Permalink to this headline"></a></h2>
<p>The xapian Python bindings accept unicode strings as well as simple strings
(ie, “str” type strings) at all places in the API which accept string data.
Any unicode strings supplied will automatically be translated into UTF-8
simple strings before being passed to the Xapian core.  The Xapian core is
largely agnostic about character encoding, but in those places where it does
process data in a character encoding dependent way it assumes that the data
is in UTF-8.  The Xapian Python bindings always return string data as simple
strings.</p>
<p>Therefore, in order to avoid issues with character encodings, you should
always pass text data to Xapian as unicode strings, or UTF-8 encoded simple
strings.  There is, however, no requirement for simple strings passed into
Xapian to be valid UTF-8 encoded strings, unless they are being passed to a
text processing routine (such as the query parser, or the stemming
algorithms).  For example, it is perfectly valid to pass arbitrary binary
data in a simple string to the <code class="docutils literal"><span class="pre">xapian.Document.set_data()</span></code>
method.</p>
<p>It is often useful to normalise unicode data before passing it to Xapian -
Xapian currently has no built-in support for normalising unicode
representations of data.  The standard python module
“<code class="docutils literal"><span class="pre">unicodedata</span></code>” provides support for normalising unicode: you
probably want the “<code class="docutils literal"><span class="pre">NFKC</span></code>” normalisation scheme: in other words,
use something like</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">unicodedata</span><span class="o">.</span><span class="n">normalize</span><span class="p">(</span><span class="s1">&#39;NFKC&#39;</span><span class="p">,</span> <span class="sa">u</span><span class="s1">&#39;foo&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>to normalise the string “foo” before passing it to Xapian.</p>
</div>
<div class="section" id="iterators">
<h2>Iterators<a class="headerlink" href="#iterators" title="Permalink to this headline"></a></h2>
<p>The iterator classes in the Xapian C++ API are wrapped in a “Pythonic” style.
The following are supported (where marked as default iterator, it means
<code class="docutils literal"><span class="pre">__iter__()</span></code> does the right
thing so you can for instance use <code class="docutils literal"><span class="pre">for</span> <span class="pre">term</span> <span class="pre">in</span> <span class="pre">document</span></code> to
iterate over terms in a Document object):</p>
<table border="1" class="docutils">
<colgroup>
<col width="18%" />
<col width="35%" />
<col width="33%" />
<col width="14%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Class</th>
<th class="head">Method</th>
<th class="head">Equivalent to</th>
<th class="head">Iterator type</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">MSet</span></code></td>
<td>default iterator</td>
<td><code class="docutils literal"><span class="pre">begin()</span></code></td>
<td><code class="docutils literal"><span class="pre">MSetIter</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">ESet</span></code></td>
<td>default iterator</td>
<td><code class="docutils literal"><span class="pre">begin()</span></code></td>
<td><code class="docutils literal"><span class="pre">ESetIter</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">Enquire</span></code></td>
<td><code class="docutils literal"><span class="pre">matching_terms()</span></code></td>
<td><code class="docutils literal"><span class="pre">get_matching_terms_begin()</span></code></td>
<td><code class="docutils literal"><span class="pre">TermIter</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">Query</span></code></td>
<td>default iterator</td>
<td><code class="docutils literal"><span class="pre">get_terms_begin()</span></code></td>
<td><code class="docutils literal"><span class="pre">TermIter</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">Database</span></code></td>
<td><code class="docutils literal"><span class="pre">allterms()</span></code> (also as default iterator)</td>
<td><code class="docutils literal"><span class="pre">allterms_begin()</span></code></td>
<td><code class="docutils literal"><span class="pre">TermIter</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">Database</span></code></td>
<td><code class="docutils literal"><span class="pre">postlist(tname)</span></code></td>
<td><code class="docutils literal"><span class="pre">postlist_begin(tname)</span></code></td>
<td><code class="docutils literal"><span class="pre">PostingIter</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">Database</span></code></td>
<td><code class="docutils literal"><span class="pre">termlist(docid)</span></code></td>
<td><code class="docutils literal"><span class="pre">termlist_begin(docid)</span></code></td>
<td><code class="docutils literal"><span class="pre">TermIter</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">Database</span></code></td>
<td><code class="docutils literal"><span class="pre">positionlist(docid,</span> <span class="pre">tname)</span></code></td>
<td><code class="docutils literal"><span class="pre">positionlist_begin(docid,</span> <span class="pre">tname)</span></code></td>
<td><code class="docutils literal"><span class="pre">PositionIter</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">Database</span></code></td>
<td><code class="docutils literal"><span class="pre">metadata_keys(prefix)</span></code></td>
<td><code class="docutils literal"><span class="pre">metadata_keys(prefix)</span></code></td>
<td><code class="docutils literal"><span class="pre">TermIter</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">Database</span></code></td>
<td><code class="docutils literal"><span class="pre">spellings()</span></code></td>
<td><code class="docutils literal"><span class="pre">spellings_begin(term)</span></code></td>
<td><code class="docutils literal"><span class="pre">TermIter</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">Database</span></code></td>
<td><code class="docutils literal"><span class="pre">synonyms(term)</span></code></td>
<td><code class="docutils literal"><span class="pre">synonyms_begin(term)</span></code></td>
<td><code class="docutils literal"><span class="pre">TermIter</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">Database</span></code></td>
<td><code class="docutils literal"><span class="pre">synonym_keys(prefix)</span></code></td>
<td><code class="docutils literal"><span class="pre">synonym_keys_begin(prefix)</span></code></td>
<td><code class="docutils literal"><span class="pre">TermIter</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">Document</span></code></td>
<td><code class="docutils literal"><span class="pre">values()</span></code></td>
<td><code class="docutils literal"><span class="pre">values_begin()</span></code></td>
<td><code class="docutils literal"><span class="pre">ValueIter</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">Document</span></code></td>
<td><code class="docutils literal"><span class="pre">termlist()</span></code> (also as default iterator)</td>
<td><code class="docutils literal"><span class="pre">termlist_begin()</span></code></td>
<td><code class="docutils literal"><span class="pre">TermIter</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">QueryParser</span></code></td>
<td><code class="docutils literal"><span class="pre">stoplist()</span></code></td>
<td><code class="docutils literal"><span class="pre">stoplist_begin()</span></code></td>
<td><code class="docutils literal"><span class="pre">TermIter</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">QueryParser</span></code></td>
<td><code class="docutils literal"><span class="pre">unstemlist(tname)</span></code></td>
<td><code class="docutils literal"><span class="pre">unstem_begin(tname)</span></code></td>
<td><code class="docutils literal"><span class="pre">TermIter</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">ValueCountMatchSpy</span></code></td>
<td><code class="docutils literal"><span class="pre">values()</span></code></td>
<td><code class="docutils literal"><span class="pre">values_begin()</span></code></td>
<td><code class="docutils literal"><span class="pre">TermIter</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">ValueCountMatchSpy</span></code></td>
<td><code class="docutils literal"><span class="pre">top_values()</span></code></td>
<td><code class="docutils literal"><span class="pre">top_values_begin()</span></code></td>
<td><code class="docutils literal"><span class="pre">TermIter</span></code></td>
</tr>
</tbody>
</table>
<p>The pythonic iterators generally return Python objects, with properties
available as attribute values, with lazy evaluation where appropriate.  An
exception is the <code class="docutils literal"><span class="pre">PositionIter</span></code> object returned by
<code class="docutils literal"><span class="pre">Database.positionlist</span></code>, which returns an integer.</p>
<p>The lazy evaluation is mainly transparent, but does become visible in one situation: if you keep an object returned by an iterator, without evaluating its properties to force the lazy evaluation to happen, and then move the iterator forward, the object may no longer be able to efficiently perform the lazy evaluation.  In this situation, an exception will be raised indicating that the information requested wasn’t available.  This will only happen for a few of the properties - most are either not evaluated lazily (because the underlying Xapian implementation doesn’t evaluate them lazily, so there’s no advantage in lazy evaluation), or can be accessed even after the iterator has moved.  The simplest work around is simply to evaluate any properties you wish to use which are affected by this before moving the iterator.  The complete set of iterator properties affected by this is:</p>
<ul class="simple">
<li>Database.allterms (also accessible as Database.__iter__): <strong>termfreq</strong></li>
<li>Database.termlist: <strong>termfreq</strong> and <strong>positer</strong></li>
<li>Document.termlist (also accessible as Document.__iter__): <strong>termfreq</strong> and <strong>positer</strong></li>
<li>Database.postlist: <strong>positer</strong></li>
</ul>
<p>In older releases, the pythonic iterators returned lists representing the
appropriate item when their <code class="docutils literal"><span class="pre">next()</span></code> method was called.  These were
removed in Xapian 1.1.0.</p>
</div>
<div class="section" id="non-pythonic-iterators">
<h2>Non-Pythonic Iterators<a class="headerlink" href="#non-pythonic-iterators" title="Permalink to this headline"></a></h2>
<p>Before the pythonic iterator wrappers were added, the python bindings provided
thin wrappers around the C++ iterators.  However, these iterators don’t behave
like most iterators do in Python, so the pythonic iterators were implemented to
replace them.  The non-pythonic iterators were removed in Xapian 1.3.0 -
the documentation below is provided to aid migration away from them.</p>
<p>All non-pythonic iterators support <code class="docutils literal"><span class="pre">next()</span></code> and
<code class="docutils literal"><span class="pre">equals()</span></code> methods
to move through and test iterators (as for all language bindings).
MSetIterator and ESetIterator also support <code class="docutils literal"><span class="pre">prev()</span></code>.
Python-wrapped iterators also support direct comparison, so something like:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">m</span><span class="o">=</span><span class="n">mset</span><span class="o">.</span><span class="n">begin</span><span class="p">()</span>
<span class="k">while</span> <span class="n">m</span><span class="o">!=</span><span class="n">mset</span><span class="o">.</span><span class="n">end</span><span class="p">():</span>
  <span class="c1"># do something</span>
  <span class="n">m</span><span class="o">.</span><span class="n">next</span><span class="p">()</span>
</pre></div>
</div>
<p>C++ iterators are often dereferenced to get information, eg
<code class="docutils literal"><span class="pre">(*it)</span></code>. With Python these are all mapped to named methods, as
follows:</p>
<table border="1" class="docutils">
<colgroup>
<col width="45%" />
<col width="55%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Iterator</th>
<th class="head">Dereferencing method</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>PositionIterator</td>
<td><code class="docutils literal"><span class="pre">get_termpos()</span></code></td>
</tr>
<tr class="row-odd"><td>PostingIterator</td>
<td><code class="docutils literal"><span class="pre">get_docid()</span></code></td>
</tr>
<tr class="row-even"><td>TermIterator</td>
<td><code class="docutils literal"><span class="pre">get_term()</span></code></td>
</tr>
<tr class="row-odd"><td>ValueIterator</td>
<td><code class="docutils literal"><span class="pre">get_value()</span></code></td>
</tr>
<tr class="row-even"><td>MSetIterator</td>
<td><code class="docutils literal"><span class="pre">get_docid()</span></code></td>
</tr>
<tr class="row-odd"><td>ESetIterator</td>
<td><code class="docutils literal"><span class="pre">get_term()</span></code></td>
</tr>
</tbody>
</table>
<p>Other methods, such as <code class="docutils literal"><span class="pre">MSetIterator.get_document()</span></code>, are
available unchanged.</p>
</div>
<div class="section" id="mset">
<h2>MSet<a class="headerlink" href="#mset" title="Permalink to this headline"></a></h2>
<p>MSet objects have some additional methods to simplify access (these
work using the C++ array dereferencing):</p>
<table border="1" class="docutils">
<colgroup>
<col width="47%" />
<col width="53%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Method name</th>
<th class="head">Explanation</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">get_hit(index)</span></code></td>
<td>returns MSetItem at index</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">get_document_percentage(index)</span></code></td>
<td><code class="docutils literal"><span class="pre">convert_to_percent(get_hit(index))</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">get_document(index)</span></code></td>
<td><code class="docutils literal"><span class="pre">get_hit(index).get_document()</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">get_docid(index)</span></code></td>
<td><code class="docutils literal"><span class="pre">get_hit(index).get_docid()</span></code></td>
</tr>
</tbody>
</table>
<p>Additionally, the MSet has a property, <code class="docutils literal"><span class="pre">mset.items</span></code>, which returns a
list of tuples representing the MSet.  This is now deprecated - please use the
property API instead (it works in Xapian 1.0.x too).  The tuple members and the
equivalent property names are as follows:</p>
<table border="1" class="docutils">
<colgroup>
<col width="22%" />
<col width="13%" />
<col width="65%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Index</th>
<th class="head">Property name</th>
<th class="head">Contents</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">xapian.MSET_DID</span></code></td>
<td>docid</td>
<td>Document id</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">xapian.MSET_WT</span></code></td>
<td>weight</td>
<td>Weight</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">xapian.MSET_RANK</span></code></td>
<td>rank</td>
<td>Rank</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">xapian.MSET_PERCENT</span></code></td>
<td>percent</td>
<td>Percentage weight</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">xapian.MSET_DOCUMENT</span></code></td>
<td>document</td>
<td>Document object (Note: this member of the tuple was never actually set!)</td>
</tr>
</tbody>
</table>
<p>Two MSet objects are equal if they have the same number and maximum possible
number of members, and if every document member of the first MSet exists at the
same index in the second MSet, with the same weight.</p>
</div>
<div class="section" id="eset">
<h2>ESet<a class="headerlink" href="#eset" title="Permalink to this headline"></a></h2>
<p>The ESet has a property, <code class="docutils literal"><span class="pre">eset.items</span></code>, which returns a list of
tuples representing the ESet.  This is now deprecated - please use the
property API instead (it works in Xapian 1.0.x too).  The tuple members and the
equivalent property names are as follows:</p>
<table border="1" class="docutils">
<colgroup>
<col width="48%" />
<col width="30%" />
<col width="22%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Index</th>
<th class="head">Property name</th>
<th class="head">Contents</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">xapian.ESET_TNAME</span></code></td>
<td>term</td>
<td>Term name</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">xapian.ESET_WT</span></code></td>
<td>weight</td>
<td>Weight</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="non-class-functions">
<h2>Non-Class Functions<a class="headerlink" href="#non-class-functions" title="Permalink to this headline"></a></h2>
<p>The C++ API contains a few non-class functions (the Database factory
functions, and some functions reporting version information), which are
wrapped like so for Python:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">Xapian::version_string()</span></code> is wrapped as <code class="docutils literal"><span class="pre">xapian.version_string()</span></code></li>
<li><code class="docutils literal"><span class="pre">Xapian::major_version()</span></code> is wrapped as <code class="docutils literal"><span class="pre">xapian.major_version()</span></code></li>
<li><code class="docutils literal"><span class="pre">Xapian::minor_version()</span></code> is wrapped as <code class="docutils literal"><span class="pre">xapian.minor_version()</span></code></li>
<li><code class="docutils literal"><span class="pre">Xapian::revision()</span></code> is wrapped as <code class="docutils literal"><span class="pre">xapian.revision()</span></code></li>
<li><code class="docutils literal"><span class="pre">Xapian::Auto::open_stub()</span></code> is wrapped as <code class="docutils literal"><span class="pre">xapian.open_stub()</span></code> (now deprecated)</li>
<li><code class="docutils literal"><span class="pre">Xapian::Chert::open()</span></code> is wrapped as <code class="docutils literal"><span class="pre">xapian.chert_open()</span></code> (now deprecated)</li>
<li><code class="docutils literal"><span class="pre">Xapian::InMemory::open()</span></code> is wrapped as <code class="docutils literal"><span class="pre">xapian.inmemory_open()</span></code> (now deprecated)</li>
<li><code class="docutils literal"><span class="pre">Xapian::Remote::open()</span></code> is wrapped as <code class="docutils literal"><span class="pre">xapian.remote_open()</span></code> (both the TCP and “program” versions are wrapped - the SWIG wrapper checks the parameter list to decide which to call).</li>
<li><code class="docutils literal"><span class="pre">Xapian::Remote::open_writable()</span></code> is wrapped as <code class="docutils literal"><span class="pre">xapian.remote_open_writable()</span></code> (both the TCP and “program” versions are wrapped - the SWIG wrapper checks the parameter list to decide which to call).</li>
</ul>
</div>
<div class="section" id="query">
<h2>Query<a class="headerlink" href="#query" title="Permalink to this headline"></a></h2>
<p>In C++ there’s a Xapian::Query constructor which takes a query operator and
start/end iterators specifying a number of terms or queries, plus an optional
parameter.  In Python, this is wrapped to accept any Python sequence (for
example a list or tuple) to give the terms/queries, and you can specify
a mixture of terms and queries if you wish.  For example:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">subq</span> <span class="o">=</span> <span class="n">xapian</span><span class="o">.</span><span class="n">Query</span><span class="p">(</span><span class="n">xapian</span><span class="o">.</span><span class="n">Query</span><span class="o">.</span><span class="n">OP_AND</span><span class="p">,</span> <span class="s2">&quot;hello&quot;</span><span class="p">,</span> <span class="s2">&quot;world&quot;</span><span class="p">)</span>
<span class="n">q</span> <span class="o">=</span> <span class="n">xapian</span><span class="o">.</span><span class="n">Query</span><span class="p">(</span><span class="n">xapian</span><span class="o">.</span><span class="n">Query</span><span class="o">.</span><span class="n">OP_AND</span><span class="p">,</span> <span class="p">[</span><span class="n">subq</span><span class="p">,</span> <span class="s2">&quot;foo&quot;</span><span class="p">,</span> <span class="n">xapian</span><span class="o">.</span><span class="n">Query</span><span class="p">(</span><span class="s2">&quot;bar&quot;</span><span class="p">,</span> <span class="mi">2</span><span class="p">)])</span>
</pre></div>
</div>
<div class="section" id="matchall-and-matchnothing">
<h3>MatchAll and MatchNothing<a class="headerlink" href="#matchall-and-matchnothing" title="Permalink to this headline"></a></h3>
<p>As of 1.1.1, these are wrapped as <code class="docutils literal"><span class="pre">xapian.Query.MatchAll</span></code> and
<code class="docutils literal"><span class="pre">xapian.Query.MatchNothing</span></code>.</p>
</div>
</div>
<div class="section" id="matchdecider">
<h2>MatchDecider<a class="headerlink" href="#matchdecider" title="Permalink to this headline"></a></h2>
<p>Custom MatchDeciders can be created in Python; simply subclass
xapian.MatchDecider, ensure you call the super-constructor, and define a
__call__ method that will do the work. The simplest example (which does nothing
useful) would be as follows:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">mymatchdecider</span><span class="p">(</span><span class="n">xapian</span><span class="o">.</span><span class="n">MatchDecider</span><span class="p">):</span>
  <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="n">xapian</span><span class="o">.</span><span class="n">MatchDecider</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>

  <span class="k">def</span> <span class="nf">__call__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">doc</span><span class="p">):</span>
    <span class="k">return</span> <span class="mi">1</span>
</pre></div>
</div>
</div>
<div class="section" id="valuerangeprocessors">
<h2>ValueRangeProcessors<a class="headerlink" href="#valuerangeprocessors" title="Permalink to this headline"></a></h2>
<p>The ValueRangeProcessor class (and its subclasses) provide an operator() method
(which is exposed in python as a __call__() method, making the class instances
into callables).  This method checks whether a beginning and end of a range are
in a format understood by the ValueRangeProcessor, and if so, converts the
beginning and end into strings which sort appropriately.  ValueRangeProcessors
can be defined in python (and then passed to the QueryParser), or there are
several default built-in ones which can be used.</p>
<p>Unfortunately, in C++ the operator() method takes two std::string arguments by
reference, and returns values by modifying these arguments.  This is not
possible in Python, since strings are immutable objects.  Instead, in the
Python implementation, when the __call__ method is called, the resulting values
of these arguments are returned as part of a tuple.  The operator() method in
C++ returns a value number; the return value of __call__ in python consists of
a 3-tuple starting with this value number, followed by the returned “begin”
value, followed by the returned “end” value.  For example:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">vrp</span> <span class="o">=</span> <span class="n">xapian</span><span class="o">.</span><span class="n">NumberValueRangeProcessor</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="s1">&#39;$&#39;</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span>
<span class="n">a</span> <span class="o">=</span> <span class="s1">&#39;$10&#39;</span>
<span class="n">b</span> <span class="o">=</span> <span class="s1">&#39;20&#39;</span>
<span class="n">slot</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span> <span class="o">=</span> <span class="n">vrp</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span>
</pre></div>
</div>
<p>Additionally, a ValueRangeProcessor may be implemented in Python.  The Python
implementation should override the __call__() method with its own
implementation, and, again, since it cannot return values by reference, it
should return a tuple of (value number, begin, end).  For example:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">MyVRP</span><span class="p">(</span><span class="n">xapian</span><span class="o">.</span><span class="n">ValueRangeProcessor</span><span class="p">):</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">xapian</span><span class="o">.</span><span class="n">ValueRangeProcessor</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
    <span class="k">def</span> <span class="nf">__call__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">begin</span><span class="p">,</span> <span class="n">end</span><span class="p">):</span>
        <span class="k">return</span> <span class="p">(</span><span class="mi">7</span><span class="p">,</span> <span class="s2">&quot;A&quot;</span><span class="o">+</span><span class="n">begin</span><span class="p">,</span> <span class="s2">&quot;B&quot;</span><span class="o">+</span><span class="n">end</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="apache-and-mod-python-mod-wsgi">
<h2>Apache and mod_python/mod_wsgi<a class="headerlink" href="#apache-and-mod-python-mod-wsgi" title="Permalink to this headline"></a></h2>
<p>Prior to Xapian 1.3.0, you had to tell mod_python and mod_wsgi to run
applications which use Xapian in the main interpreter.  Xapian 1.3.0 no
longer uses the simplified GIL state API, and so this restriction should
no longer apply.</p>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Introduction</a><ul>
<li><a class="reference internal" href="#exceptions">Exceptions</a></li>
<li><a class="reference internal" href="#unicode">Unicode</a></li>
<li><a class="reference internal" href="#iterators">Iterators</a></li>
<li><a class="reference internal" href="#non-pythonic-iterators">Non-Pythonic Iterators</a></li>
<li><a class="reference internal" href="#mset">MSet</a></li>
<li><a class="reference internal" href="#eset">ESet</a></li>
<li><a class="reference internal" href="#non-class-functions">Non-Class Functions</a></li>
<li><a class="reference internal" href="#query">Query</a><ul>
<li><a class="reference internal" href="#matchall-and-matchnothing">MatchAll and MatchNothing</a></li>
</ul>
</li>
<li><a class="reference internal" href="#matchdecider">MatchDecider</a></li>
<li><a class="reference internal" href="#valuerangeprocessors">ValueRangeProcessors</a></li>
<li><a class="reference internal" href="#apache-and-mod-python-mod-wsgi">Apache and mod_python/mod_wsgi</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="index.html"
                        title="previous chapter">Welcome to Xapian Python Bindings’s documentation!</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="examples.html"
                        title="next chapter">Examples</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="_sources/introduction.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <div><input type="text" name="q" /></div>
      <div><input type="submit" value="Go" /></div>
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="examples.html" title="Examples"
             >next</a> |</li>
        <li class="right" >
          <a href="index.html" title="Welcome to Xapian Python Bindings’s documentation!"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">Xapian Python Bindings 1.4.5 documentation</a> &#187;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright .
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.6.7.
    </div>
  </body>
</html>