File: Zend_Search_Lucene-Queries.xml

package info (click to toggle)
zendframework 1.12.9%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 133,584 kB
  • sloc: xml: 1,311,829; php: 570,173; sh: 170; makefile: 125; sql: 121
file content (786 lines) | stat: -rw-r--r-- 26,293 bytes parent folder | download | duplicates (2)
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
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect1 id="zend.search.lucene.query-api">
    <title>Query Construction API</title>

    <para>
        In addition to parsing a string query automatically it's also possible to construct them
        with the query <acronym>API</acronym>.
    </para>

    <para>
        User queries can be combined with queries created through the query <acronym>API</acronym>.
        Simply use the query parser to construct a query from a string:
    </para>

    <programlisting language="php"><![CDATA[
$query = Zend_Search_Lucene_Search_QueryParser::parse($queryString);
]]></programlisting>

    <sect2 id="zend.search.lucene.queries.exceptions">
        <title>Query Parser Exceptions</title>

        <para>
            The query parser may generate two types of exceptions:

            <itemizedlist>
                <listitem>
                    <para>
                        <classname>Zend_Search_Lucene_Exception</classname> is thrown if something
                        goes wrong in the query parser itself.
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <classname>Zend_Search_Lucene_Search_QueryParserException</classname> is
                        thrown when there is an error in the query syntax.
                    </para>
                </listitem>
            </itemizedlist>

            It's a good idea to catch
            <classname>Zend_Search_Lucene_Search_QueryParserException</classname>s and handle them
            appropriately:
        </para>

        <programlisting language="php"><![CDATA[
try {
    $query = Zend_Search_Lucene_Search_QueryParser::parse($queryString);
} catch (Zend_Search_Lucene_Search_QueryParserException $e) {
    echo "Query syntax error: " . $e->getMessage() . "\n";
}
]]></programlisting>

        <para>
            The same technique should be used for the find() method of a
            <classname>Zend_Search_Lucene</classname> object.
        </para>

        <para>
            Starting in 1.5, query parsing exceptions are suppressed by default. If query doesn't
            conform query language, then it's tokenized using current default analyzer and all
            tokenized terms are used for searching. Use
            <methodname>Zend_Search_Lucene_Search_QueryParser::dontSuppressQueryParsingExceptions()</methodname>
            method to turn exceptions on.
            <methodname>Zend_Search_Lucene_Search_QueryParser::suppressQueryParsingExceptions()</methodname>
            and
            <methodname>Zend_Search_Lucene_Search_QueryParser::queryParsingExceptionsSuppressed()</methodname>
            methods are also intended to manage exceptions handling behavior.
        </para>
    </sect2>

    <sect2 id="zend.search.lucene.queries.term-query">
        <title>Term Query</title>

        <para>
            Term queries can be used for searching with a single term.
        </para>

        <para>
            Query string:
        </para>

        <programlisting language="querystring"><![CDATA[
word1
]]></programlisting>

        <para>or</para>

        <para>
            Query construction by <acronym>API</acronym>:
        </para>

        <programlisting language="php"><![CDATA[
$term  = new Zend_Search_Lucene_Index_Term('word1', 'field1');
$query = new Zend_Search_Lucene_Search_Query_Term($term);
$hits  = $index->find($query);
]]></programlisting>

        <para>
            The term field is optional. <classname>Zend_Search_Lucene</classname> searches through
            all indexed fields in each document if the field is not specified:
        </para>

        <programlisting language="php"><![CDATA[
// Search for 'word1' in all indexed fields
$term  = new Zend_Search_Lucene_Index_Term('word1');
$query = new Zend_Search_Lucene_Search_Query_Term($term);
$hits  = $index->find($query);
]]></programlisting>
    </sect2>

    <sect2 id="zend.search.lucene.queries.multiterm-query">
        <title>Multi-Term Query</title>

        <para>
            Multi-term queries can be used for searching with a set of terms.
        </para>

        <para>
            Each term in a set can be defined as <emphasis>required</emphasis>,
            <emphasis>prohibited</emphasis>, or <emphasis>neither</emphasis>.

            <itemizedlist>
                <listitem>
                    <para>
                        <emphasis>required</emphasis> means that documents not matching this term
                        will not match the query;
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <emphasis>prohibited</emphasis> means that documents matching this term will
                        not match the query;
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <emphasis>neither</emphasis>, in which case matched documents are neither
                        prohibited from, nor required to, match the term. A document must match at
                        least 1 term, however, to match the query.
                    </para>
                </listitem>
            </itemizedlist>
        </para>

        <para>
            If optional terms are added to a query with required terms, both queries will have the
            same result set but the optional terms may affect the score of the matched documents.
        </para>

        <para>
            Both search methods can be used for multi-term queries.
        </para>

        <para>
            Query string:
        </para>

        <programlisting language="querystring"><![CDATA[
+word1 author:word2 -word3
]]></programlisting>

        <itemizedlist>
            <listitem><para>'+' is used to define a required term.</para></listitem>
            <listitem><para>'-' is used to define a prohibited term.</para></listitem>

            <listitem>
                <para>
                    'field:' prefix is used to indicate a document field for a search.
                    If it's omitted, then all fields are searched.
                </para>
            </listitem>
        </itemizedlist>

        <para>or</para>

        <para>
            Query construction by <acronym>API</acronym>:
        </para>

        <programlisting language="php"><![CDATA[
$query = new Zend_Search_Lucene_Search_Query_MultiTerm();

$query->addTerm(new Zend_Search_Lucene_Index_Term('word1'), true);
$query->addTerm(new Zend_Search_Lucene_Index_Term('word2', 'author'),
                null);
$query->addTerm(new Zend_Search_Lucene_Index_Term('word3'), false);

$hits  = $index->find($query);
]]></programlisting>

        <para>
            It's also possible to specify terms list within MultiTerm query constructor:
        </para>

        <programlisting language="php"><![CDATA[
$terms = array(new Zend_Search_Lucene_Index_Term('word1'),
               new Zend_Search_Lucene_Index_Term('word2', 'author'),
               new Zend_Search_Lucene_Index_Term('word3'));
$signs = array(true, null, false);

$query = new Zend_Search_Lucene_Search_Query_MultiTerm($terms, $signs);

$hits  = $index->find($query);
]]></programlisting>

        <para>
            The <varname>$signs</varname> array contains information about the term type:

            <itemizedlist>
                <listitem>
                    <para>
                        <constant>TRUE</constant> is used to define required term.
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <constant>FALSE</constant> is used to define prohibited term.
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <constant>NULL</constant> is used to define a term that is neither required
                        nor prohibited.
                    </para>
                </listitem>
            </itemizedlist>
        </para>
    </sect2>

    <sect2 id="zend.search.lucene.queries.boolean-query">
        <title>Boolean Query</title>

        <para>
            Boolean queries allow to construct query using other queries and boolean operators.
        </para>

        <para>
            Each subquery in a set can be defined as <emphasis>required</emphasis>,
            <emphasis>prohibited</emphasis>, or <emphasis>optional</emphasis>.

            <itemizedlist>
                <listitem>
                    <para>
                        <emphasis>required</emphasis> means that documents not matching this
                        subquery will not match the query;
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <emphasis>prohibited</emphasis> means that documents matching this subquery
                        will not match the query;
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <emphasis>optional</emphasis>, in which case matched documents are neither
                        prohibited from, nor required to, match the subquery. A document must match
                        at least 1 subquery, however, to match the query.
                    </para>
                </listitem>
            </itemizedlist>
        </para>

        <para>
            If optional subqueries are added to a query with required subqueries, both queries will
            have the same result set but the optional subqueries may affect the score of the matched
            documents.
        </para>

        <para>
            Both search methods can be used for boolean queries.
        </para>

        <para>
            Query string:
        </para>

        <programlisting language="querystring"><![CDATA[
+(word1 word2 word3) (author:word4 author:word5) -(word6)
]]></programlisting>

        <itemizedlist>
            <listitem>
                <para>
                    '+' is used to define a required subquery.
                </para>
            </listitem>

            <listitem>
                <para>
                    '-' is used to define a prohibited subquery.
                </para>
            </listitem>

            <listitem>
                <para>
                    'field:' prefix is used to indicate a document field for a search.
                    If it's omitted, then all fields are searched.
                </para>
            </listitem>
        </itemizedlist>

        <para>or</para>

        <para>
            Query construction by <acronym>API</acronym>:
        </para>

        <programlisting language="php"><![CDATA[
$query = new Zend_Search_Lucene_Search_Query_Boolean();

$subquery1 = new Zend_Search_Lucene_Search_Query_MultiTerm();
$subquery1->addTerm(new Zend_Search_Lucene_Index_Term('word1'));
$subquery1->addTerm(new Zend_Search_Lucene_Index_Term('word2'));
$subquery1->addTerm(new Zend_Search_Lucene_Index_Term('word3'));

$subquery2 = new Zend_Search_Lucene_Search_Query_MultiTerm();
$subquery2->addTerm(new Zend_Search_Lucene_Index_Term('word4', 'author'));
$subquery2->addTerm(new Zend_Search_Lucene_Index_Term('word5', 'author'));

$term6 = new Zend_Search_Lucene_Index_Term('word6');
$subquery3 = new Zend_Search_Lucene_Search_Query_Term($term6);

$query->addSubquery($subquery1, true  /* required */);
$query->addSubquery($subquery2, null  /* optional */);
$query->addSubquery($subquery3, false /* prohibited */);

$hits  = $index->find($query);
]]></programlisting>

        <para>
            It's also possible to specify subqueries list within Boolean query constructor:
        </para>

        <programlisting language="php"><![CDATA[
...
$subqueries = array($subquery1, $subquery2, $subquery3);
$signs = array(true, null, false);

$query = new Zend_Search_Lucene_Search_Query_Boolean($subqueries, $signs);

$hits  = $index->find($query);
]]></programlisting>

        <para>
            The <varname>$signs</varname> array contains information about the subquery type:

            <itemizedlist>
                <listitem>
                    <para>
                        <constant>TRUE</constant> is used to define required subquery.
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <constant>FALSE</constant> is used to define prohibited subquery.
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <constant>NULL</constant> is used to define a subquery that is neither
                        required nor prohibited.
                    </para>
                </listitem>
            </itemizedlist>
        </para>

        <para>
            Each query which uses boolean operators can be rewritten using signs notation and
            constructed using <acronym>API</acronym>. For example:
        </para>

        <programlisting language="querystring"><![CDATA[
word1 AND (word2 AND word3 AND NOT word4) OR word5
]]></programlisting>

        <para>
            is equivalent to
        </para>

        <programlisting language="querystring"><![CDATA[
(+(word1) +(+word2 +word3 -word4)) (word5)
]]></programlisting>
    </sect2>

    <sect2 id="zend.search.lucene.queries.wildcard">
        <title>Wildcard Query</title>

        <para>
            Wildcard queries can be used to search for documents containing strings matching
            specified patterns.
        </para>

        <para>
            The '?' symbol is used as a single character wildcard.
        </para>

        <para>
            The '*' symbol is used as a multiple character wildcard.
        </para>

        <para>
            Query string:
        </para>

        <programlisting language="querystring"><![CDATA[
field1:test*
]]></programlisting>

        <para>or</para>

        <para>
            Query construction by <acronym>API</acronym>:
        </para>

        <programlisting language="php"><![CDATA[
$pattern = new Zend_Search_Lucene_Index_Term('test*', 'field1');
$query = new Zend_Search_Lucene_Search_Query_Wildcard($pattern);
$hits  = $index->find($query);
]]></programlisting>

        <para>
            The term field is optional. <classname>Zend_Search_Lucene</classname> searches through
            all fields on each document if a field is not specified:
        </para>

        <programlisting language="php"><![CDATA[
$pattern = new Zend_Search_Lucene_Index_Term('test*');
$query = new Zend_Search_Lucene_Search_Query_Wildcard($pattern);
$hits  = $index->find($query);
]]></programlisting>
    </sect2>

    <sect2 id="zend.search.lucene.queries.fuzzy">
        <title>Fuzzy Query</title>

        <para>
            Fuzzy queries can be used to search for documents containing strings matching terms
            similar to specified term.
        </para>

        <para>
            Query string:
        </para>

        <programlisting language="querystring"><![CDATA[
field1:test~
]]></programlisting>

        <para>
            This query matches documents containing 'test' 'text' 'best' words and others.
        </para>

        <para>or</para>

        <para>
            Query construction by <acronym>API</acronym>:
        </para>

        <programlisting language="php"><![CDATA[
$term = new Zend_Search_Lucene_Index_Term('test', 'field1');
$query = new Zend_Search_Lucene_Search_Query_Fuzzy($term);
$hits  = $index->find($query);
]]></programlisting>

        <para>
            Optional similarity can be specified after "~" sign.
        </para>

        <para>
            Query string:
        </para>

        <programlisting language="querystring"><![CDATA[
field1:test~0.4
]]></programlisting>

        <para>or</para>

        <para>
            Query construction by <acronym>API</acronym>:
        </para>

        <programlisting language="php"><![CDATA[
$term = new Zend_Search_Lucene_Index_Term('test', 'field1');
$query = new Zend_Search_Lucene_Search_Query_Fuzzy($term, 0.4);
$hits  = $index->find($query);
]]></programlisting>

        <para>
            The term field is optional. <classname>Zend_Search_Lucene</classname> searches through
            all fields on each document if a field is not specified:
        </para>

        <programlisting language="php"><![CDATA[
$term = new Zend_Search_Lucene_Index_Term('test');
$query = new Zend_Search_Lucene_Search_Query_Fuzzy($term);
$hits  = $index->find($query);
]]></programlisting>
    </sect2>

    <sect2 id="zend.search.lucene.queries.phrase-query">
        <title>Phrase Query</title>

        <para>
            Phrase Queries can be used to search for a phrase within documents.
        </para>

        <para>
            Phrase Queries are very flexible and allow the user or developer to search for exact
            phrases as well as 'sloppy' phrases.
        </para>

        <para>
            Phrases can also contain gaps or terms in the same places; they can be generated by
            the analyzer for different purposes. For example, a term can be duplicated to increase
            the term its weight, or several synonyms can be placed into a single position.
        </para>

        <programlisting language="php"><![CDATA[
$query1 = new Zend_Search_Lucene_Search_Query_Phrase();

// Add 'word1' at 0 relative position.
$query1->addTerm(new Zend_Search_Lucene_Index_Term('word1'));

// Add 'word2' at 1 relative position.
$query1->addTerm(new Zend_Search_Lucene_Index_Term('word2'));

// Add 'word3' at 3 relative position.
$query1->addTerm(new Zend_Search_Lucene_Index_Term('word3'), 3);

...

$query2 = new Zend_Search_Lucene_Search_Query_Phrase(
                array('word1', 'word2', 'word3'), array(0,1,3));

...

// Query without a gap.
$query3 = new Zend_Search_Lucene_Search_Query_Phrase(
                array('word1', 'word2', 'word3'));

...

$query4 = new Zend_Search_Lucene_Search_Query_Phrase(
                array('word1', 'word2'), array(0,1), 'annotation');
]]></programlisting>

        <para>
            A phrase query can be constructed in one step with a class constructor or step by step
            with <methodname>Zend_Search_Lucene_Search_Query_Phrase::addTerm()</methodname> method
            calls.
        </para>

        <para>
            <classname>Zend_Search_Lucene_Search_Query_Phrase</classname> class constructor takes
            three optional arguments:
        </para>

        <programlisting language="php"><![CDATA[
Zend_Search_Lucene_Search_Query_Phrase(
    [array $terms[, array $offsets[, string $field]]]
);
]]></programlisting>

        <para>
            The <varname>$terms</varname> parameter is an array of strings that contains a set of
            phrase terms. If it's omitted or equal to <constant>NULL</constant>, then an empty query
            is constructed.
        </para>

        <para>
            The <varname>$offsets</varname> parameter is an array of integers that contains offsets
            of terms in a phrase. If it's omitted or equal to <constant>NULL</constant>, then the
            terms' positions are assumed to be sequential with no gaps.
        </para>

        <para>
            The <varname>$field</varname> parameter is a string that indicates the document field
            to search. If it's omitted or equal to <constant>NULL</constant>, then the default field
            is searched.
        </para>

        <para>
            Thus:
        </para>

        <programlisting language="php"><![CDATA[
$query =
    new Zend_Search_Lucene_Search_Query_Phrase(array('zend', 'framework'));
]]></programlisting>

        <para>
            will search for the phrase 'zend framework' in all fields.
        </para>

        <programlisting language="php"><![CDATA[
$query = new Zend_Search_Lucene_Search_Query_Phrase(
                 array('zend', 'download'), array(0, 2)
             );
]]></programlisting>

        <para>
            will search for the phrase 'zend ????? download' and match 'zend platform download',
            'zend studio download', 'zend core download', 'zend framework download', and so on.
        </para>

        <programlisting language="php"><![CDATA[
$query = new Zend_Search_Lucene_Search_Query_Phrase(
                 array('zend', 'framework'), null, 'title'
             );
]]></programlisting>

        <para>
            will search for the phrase 'zend framework' in the 'title' field.
        </para>

        <para>
            <methodname>Zend_Search_Lucene_Search_Query_Phrase::addTerm()</methodname> takes two
            arguments, a required <classname>Zend_Search_Lucene_Index_Term</classname> object and an
            optional position:
        </para>

        <programlisting language="php"><![CDATA[
Zend_Search_Lucene_Search_Query_Phrase::addTerm(
    Zend_Search_Lucene_Index_Term $term[, integer $position]
);
]]></programlisting>

        <para>
            The <varname>$term</varname> parameter describes the next term in the phrase. It must
            indicate the same field as previous terms, or an exception will be thrown.
        </para>

        <para>
            The <varname>$position</varname> parameter indicates the term position in the phrase.
        </para>

        <para>
            Thus:
        </para>

        <programlisting language="php"><![CDATA[
$query = new Zend_Search_Lucene_Search_Query_Phrase();
$query->addTerm(new Zend_Search_Lucene_Index_Term('zend'));
$query->addTerm(new Zend_Search_Lucene_Index_Term('framework'));
]]></programlisting>

        <para>
            will search for the phrase 'zend framework'.
        </para>

        <programlisting language="php"><![CDATA[
$query = new Zend_Search_Lucene_Search_Query_Phrase();
$query->addTerm(new Zend_Search_Lucene_Index_Term('zend'), 0);
$query->addTerm(new Zend_Search_Lucene_Index_Term('framework'), 2);
]]></programlisting>

        <para>
            will search for the phrase 'zend ????? download' and match 'zend platform download',
            'zend studio download', 'zend core download', 'zend framework download', and so on.
        </para>

        <programlisting language="php"><![CDATA[
$query = new Zend_Search_Lucene_Search_Query_Phrase();
$query->addTerm(new Zend_Search_Lucene_Index_Term('zend', 'title'));
$query->addTerm(new Zend_Search_Lucene_Index_Term('framework', 'title'));
]]></programlisting>

        <para>
            will search for the phrase 'zend framework' in the 'title' field.
        </para>

        <para>
            The slop factor sets the number of other words permitted between specified words in the
            query phrase. If set to zero, then the corresponding query is an exact phrase search.
            For larger values this works like the WITHIN or NEAR operators.
        </para>

        <para>
            The slop factor is in fact an edit distance, where the edits correspond to moving terms
            in the query phrase. For example, to switch the order of two words requires two moves
            (the first move places the words atop one another), so to permit re-orderings of
            phrases, the slop factor must be at least two.
        </para>

        <para>
            More exact matches are scored higher than sloppier matches; thus, search results are
            sorted by exactness. The slop is zero by default, requiring exact matches.
        </para>

        <para>
            The slop factor can be assigned after query creation:
        </para>

        <programlisting language="php"><![CDATA[
// Query without a gap.
$query =
    new Zend_Search_Lucene_Search_Query_Phrase(array('word1', 'word2'));

// Search for 'word1 word2', 'word1 ... word2'
$query->setSlop(1);
$hits1 = $index->find($query);

// Search for 'word1 word2', 'word1 ... word2',
// 'word1 ... ... word2', 'word2 word1'
$query->setSlop(2);
$hits2 = $index->find($query);
]]></programlisting>
    </sect2>

    <sect2 id="zend.search.lucene.queries.range">
        <title>Range Query</title>

        <para>
            <link linkend="zend.search.lucene.query-language.range">Range queries</link> are
            intended for searching terms within specified interval.
        </para>

        <para>
            Query string:
        </para>

        <programlisting language="querystring"><![CDATA[
mod_date:[20020101 TO 20030101]
title:{Aida TO Carmen}
]]></programlisting>

        <para>or</para>

        <para>
            Query construction by <acronym>API</acronym>:
        </para>

        <programlisting language="php"><![CDATA[
$from = new Zend_Search_Lucene_Index_Term('20020101', 'mod_date');
$to   = new Zend_Search_Lucene_Index_Term('20030101', 'mod_date');
$query = new Zend_Search_Lucene_Search_Query_Range(
                 $from, $to, true // inclusive
             );
$hits  = $index->find($query);
]]></programlisting>

        <para>
            Term fields are optional. <classname>Zend_Search_Lucene</classname> searches through all
            fields if the field is not specified:
        </para>

        <programlisting language="php"><![CDATA[
$from = new Zend_Search_Lucene_Index_Term('Aida');
$to   = new Zend_Search_Lucene_Index_Term('Carmen');
$query = new Zend_Search_Lucene_Search_Query_Range(
                 $from, $to, false // non-inclusive
             );
$hits  = $index->find($query);
]]></programlisting>

        <para>
            Either (but not both) of the boundary terms may be set to <constant>NULL</constant>.
            <classname>Zend_Search_Lucene</classname> searches from the beginning or
            up to the end of the dictionary for the specified field(s) in this case:
        </para>

        <programlisting language="php"><![CDATA[
// searches for ['20020101' TO ...]
$from = new Zend_Search_Lucene_Index_Term('20020101', 'mod_date');
$query = new Zend_Search_Lucene_Search_Query_Range(
                 $from, null, true // inclusive
             );
$hits  = $index->find($query);
]]></programlisting>
    </sect2>
</sect1>
<!--
vim:se ts=4 sw=4 et:
-->