~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to lucene/src/site/build/site/queryparsersyntax.html

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
 
<html>
3
 
<head>
4
 
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
 
<meta content="Apache Forrest" name="Generator">
6
 
<meta name="Forrest-version" content="0.9">
7
 
<meta name="Forrest-skin-name" content="lucene">
8
 
<title>
9
 
        Apache Lucene - Query Parser Syntax
10
 
                </title>
11
 
<link type="text/css" href="skin/basic.css" rel="stylesheet">
12
 
<link media="screen" type="text/css" href="skin/screen.css" rel="stylesheet">
13
 
<link media="print" type="text/css" href="skin/print.css" rel="stylesheet">
14
 
<link type="text/css" href="skin/profile.css" rel="stylesheet">
15
 
<script src="skin/getBlank.js" language="javascript" type="text/javascript"></script><script src="skin/getMenu.js" language="javascript" type="text/javascript"></script><script src="skin/fontsize.js" language="javascript" type="text/javascript"></script>
16
 
<link rel="shortcut icon" href="images/favicon.ico">
17
 
</head>
18
 
<body onload="init()">
19
 
<script type="text/javascript">ndeSetTextSize();</script>
20
 
<div id="top">
21
 
<!--+
22
 
    |breadtrail
23
 
    +-->
24
 
<div class="breadtrail">
25
 
<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://lucene.apache.org/">Lucene</a><script src="skin/breadcrumbs.js" language="JavaScript" type="text/javascript"></script>
26
 
</div>
27
 
<!--+
28
 
    |header
29
 
    +-->
30
 
<div class="header">
31
 
<!--+
32
 
    |start group logo
33
 
    +-->
34
 
<div class="grouplogo">
35
 
<a href="http://lucene.apache.org/"><img class="logoImage" alt="Lucene" src="http://www.apache.org/images/asf_logo_simple.png" title="Apache Lucene"></a>
36
 
</div>
37
 
<!--+
38
 
    |end group logo
39
 
    +-->
40
 
<!--+
41
 
    |start Project Logo
42
 
    +-->
43
 
<div class="projectlogo">
44
 
<a href="http://lucene.apache.org/java/"><img class="logoImage" alt="Lucene" src="http://lucene.apache.org/images/lucene_green_300.gif" title="Apache Lucene is a high-performance, full-featured text search engine library written entirely in
45
 
      Java. It is a technology suitable for nearly any application that requires full-text search, especially cross-platform."></a>
46
 
</div>
47
 
<!--+
48
 
    |end Project Logo
49
 
    +-->
50
 
<!--+
51
 
    |start Search
52
 
    +-->
53
 
<div class="searchbox">
54
 
<form action="http://search.lucidimagination.com/p:lucene" method="get" class="roundtopsmall">
55
 
<input onFocus="getBlank (this, 'Search the site with Lucene');" size="25" name="q" id="query" type="text" value="Search the site with Lucene">&nbsp; 
56
 
                    <input name="Search" value="Search" type="submit">
57
 
</form>
58
 
<div style="position: relative; top: -5px; left: -10px">Powered by <a href="http://www.lucidimagination.com" style="color: #033268">Lucid Imagination</a>
59
 
</div>
60
 
</div>
61
 
<!--+
62
 
    |end search
63
 
    +-->
64
 
<!--+
65
 
    |start Tabs
66
 
    +-->
67
 
<ul id="tabs">
68
 
<li class="current">
69
 
<a class="selected" href="http://lucene.apache.org/java/docs/">Main</a>
70
 
</li>
71
 
<li>
72
 
<a class="unselected" href="http://wiki.apache.org/lucene-java">Wiki</a>
73
 
</li>
74
 
<li class="current">
75
 
<a class="selected" href="index.html">Lucene 3.5 Documentation</a>
76
 
</li>
77
 
</ul>
78
 
<!--+
79
 
    |end Tabs
80
 
    +-->
81
 
</div>
82
 
</div>
83
 
<div id="main">
84
 
<div id="publishedStrip">
85
 
<!--+
86
 
    |start Subtabs
87
 
    +-->
88
 
<div id="level2tabs"></div>
89
 
<!--+
90
 
    |end Endtabs
91
 
    +-->
92
 
<script type="text/javascript"><!--
93
 
document.write("Last Published: " + document.lastModified);
94
 
//  --></script>
95
 
</div>
96
 
<!--+
97
 
    |breadtrail
98
 
    +-->
99
 
<div class="breadtrail">
100
 
 
101
 
             &nbsp;
102
 
           </div>
103
 
<!--+
104
 
    |start Menu, mainarea
105
 
    +-->
106
 
<!--+
107
 
    |start Menu
108
 
    +-->
109
 
<div id="menu">
110
 
<div onclick="SwitchMenu('menu_selected_1.1', 'skin/')" id="menu_selected_1.1Title" class="menutitle" style="background-image: url('skin/images/chapter_open.gif');">Documentation</div>
111
 
<div id="menu_selected_1.1" class="selectedmenuitemgroup" style="display: block;">
112
 
<div class="menuitem">
113
 
<a href="index.html">Overview</a>
114
 
</div>
115
 
<div onclick="SwitchMenu('menu_1.1.2', 'skin/')" id="menu_1.1.2Title" class="menutitle">Changes</div>
116
 
<div id="menu_1.1.2" class="menuitemgroup">
117
 
<div class="menuitem">
118
 
<a href="changes/Changes.html">Core</a>
119
 
</div>
120
 
<div class="menuitem">
121
 
<a href="changes/Contrib-Changes.html">Contrib</a>
122
 
</div>
123
 
</div>
124
 
<div onclick="SwitchMenu('menu_1.1.3', 'skin/')" id="menu_1.1.3Title" class="menutitle">Javadocs</div>
125
 
<div id="menu_1.1.3" class="menuitemgroup">
126
 
<div class="menuitem">
127
 
<a href="api/all/index.html">All</a>
128
 
</div>
129
 
<div class="menuitem">
130
 
<a href="api/core/index.html">Core</a>
131
 
</div>
132
 
<div class="menuitem">
133
 
<a href="api/test-framework/index.html">Test Framework</a>
134
 
</div>
135
 
<div onclick="SwitchMenu('menu_1.1.3.4', 'skin/')" id="menu_1.1.3.4Title" class="menutitle">Contrib</div>
136
 
<div id="menu_1.1.3.4" class="menuitemgroup">
137
 
<div class="menuitem">
138
 
<a href="api/contrib-analyzers/index.html">Analyzers</a>
139
 
</div>
140
 
<div class="menuitem">
141
 
<a href="api/contrib-smartcn/index.html">Smart Chinese Analyzer</a>
142
 
</div>
143
 
<div class="menuitem">
144
 
<a href="api/contrib-stempel/index.html">Stempel Polish Analyzer</a>
145
 
</div>
146
 
<div class="menuitem">
147
 
<a href="api/contrib-benchmark/index.html">Benchmark</a>
148
 
</div>
149
 
<div class="menuitem">
150
 
<a href="api/contrib-demo/index.html">Demo</a>
151
 
</div>
152
 
<div class="menuitem">
153
 
<a href="api/contrib-grouping/index.html">Grouping</a>
154
 
</div>
155
 
<div class="menuitem">
156
 
<a href="api/contrib-highlighter/index.html">Highlighter</a>
157
 
</div>
158
 
<div class="menuitem">
159
 
<a href="api/contrib-icu/index.html">ICU</a>
160
 
</div>
161
 
<div class="menuitem">
162
 
<a href="api/contrib-instantiated/index.html">Instantiated</a>
163
 
</div>
164
 
<div class="menuitem">
165
 
<a href="api/contrib-join/index.html">Join</a>
166
 
</div>
167
 
<div class="menuitem">
168
 
<a href="api/contrib-memory/index.html">Memory</a>
169
 
</div>
170
 
<div class="menuitem">
171
 
<a href="api/contrib-misc/index.html">Miscellaneous</a>
172
 
</div>
173
 
<div class="menuitem">
174
 
<a href="api/contrib-queries/index.html">Queries</a>
175
 
</div>
176
 
<div class="menuitem">
177
 
<a href="api/contrib-queryparser/index.html">Query Parser Framework</a>
178
 
</div>
179
 
<div class="menuitem">
180
 
<a href="api/contrib-remote/index.html">Remote</a>
181
 
</div>
182
 
<div class="menuitem">
183
 
<a href="api/contrib-spatial/index.html">Spatial</a>
184
 
</div>
185
 
<div class="menuitem">
186
 
<a href="api/contrib-spellchecker/index.html">Spellchecker</a>
187
 
</div>
188
 
<div class="menuitem">
189
 
<a href="api/contrib-xml-query-parser/index.html">XML Query Parser</a>
190
 
</div>
191
 
</div>
192
 
</div>
193
 
<div class="menuitem">
194
 
<a href="systemrequirements.html">System Requirements</a>
195
 
</div>
196
 
<div class="menuitem">
197
 
<a href="contributions.html">Contributions</a>
198
 
</div>
199
 
<div class="menuitem">
200
 
<a href="http://wiki.apache.org/lucene-java/LuceneFAQ">FAQ</a>
201
 
</div>
202
 
<div class="menuitem">
203
 
<a href="fileformats.html">File Formats</a>
204
 
</div>
205
 
<div class="menuitem">
206
 
<a href="gettingstarted.html">Getting Started</a>
207
 
</div>
208
 
<div class="menuitem">
209
 
<a href="lucene-contrib/index.html">Lucene Contrib</a>
210
 
</div>
211
 
<div class="menupage">
212
 
<div class="menupagetitle">Query Syntax</div>
213
 
</div>
214
 
<div class="menuitem">
215
 
<a href="scoring.html">Scoring</a>
216
 
</div>
217
 
<div class="menuitem">
218
 
<a href="http://wiki.apache.org/lucene-java">Wiki</a>
219
 
</div>
220
 
</div>
221
 
<div id="credit"></div>
222
 
<div id="roundbottom">
223
 
<img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
224
 
<!--+
225
 
  |alternative credits
226
 
  +-->
227
 
<div id="credit2"></div>
228
 
</div>
229
 
<!--+
230
 
    |end Menu
231
 
    +-->
232
 
<!--+
233
 
    |start content
234
 
    +-->
235
 
<div id="content">
236
 
<h1>
237
 
        Apache Lucene - Query Parser Syntax
238
 
                </h1>
239
 
<div id="minitoc-area">
240
 
<ul class="minitoc">
241
 
<li>
242
 
<a href="#Overview">Overview</a>
243
 
</li>
244
 
<li>
245
 
<a href="#Terms">Terms</a>
246
 
</li>
247
 
<li>
248
 
<a href="#Fields">Fields</a>
249
 
</li>
250
 
<li>
251
 
<a href="#Term Modifiers">Term Modifiers</a>
252
 
<ul class="minitoc">
253
 
<li>
254
 
<a href="#Wildcard Searches">Wildcard Searches</a>
255
 
</li>
256
 
<li>
257
 
<a href="#Fuzzy Searches">Fuzzy Searches</a>
258
 
</li>
259
 
<li>
260
 
<a href="#Proximity Searches">Proximity Searches</a>
261
 
</li>
262
 
<li>
263
 
<a href="#Range Searches">Range Searches</a>
264
 
</li>
265
 
<li>
266
 
<a href="#Boosting a Term">Boosting a Term</a>
267
 
</li>
268
 
</ul>
269
 
</li>
270
 
<li>
271
 
<a href="#Boolean operators">Boolean Operators</a>
272
 
<ul class="minitoc">
273
 
<li>
274
 
<a href="#OR"></a>
275
 
</li>
276
 
<li>
277
 
<a href="#AND">AND</a>
278
 
</li>
279
 
<li>
280
 
<a href="#+">+</a>
281
 
</li>
282
 
<li>
283
 
<a href="#NOT">NOT</a>
284
 
</li>
285
 
<li>
286
 
<a href="#-">-</a>
287
 
</li>
288
 
</ul>
289
 
</li>
290
 
<li>
291
 
<a href="#Grouping">Grouping</a>
292
 
</li>
293
 
<li>
294
 
<a href="#Field Grouping">Field Grouping</a>
295
 
</li>
296
 
<li>
297
 
<a href="#Escaping Special Characters">Escaping Special Characters</a>
298
 
</li>
299
 
</ul>
300
 
</div>
301
 
        
302
 
<a name="N10013"></a><a name="Overview"></a>
303
 
<h2 class="boxed">Overview</h2>
304
 
<div class="section">
305
 
<p>Although Lucene provides the ability to create your own
306
 
            queries through its API, it also provides a rich query
307
 
            language through the Query Parser, a lexer which
308
 
            interprets a string into a Lucene Query using JavaCC.
309
 
            </p>
310
 
<p>Generally, the query parser syntax may change from
311
 
            release to release.  This page describes the syntax as of
312
 
            the current release.  If you are using a different
313
 
            version of Lucene, please consult the copy of
314
 
            <span class="codefrag">docs/queryparsersyntax.html</span> that was distributed
315
 
            with the version you are using.
316
 
            </p>
317
 
<p>
318
 
            Before choosing to use the provided Query Parser, please consider the following:
319
 
            <ol>
320
 
            
321
 
<li>If you are programmatically generating a query string and then
322
 
            parsing it with the query parser then you should seriously consider building
323
 
            your queries directly with the query API.  In other words, the query
324
 
            parser is designed for human-entered text, not for program-generated
325
 
            text.</li>
326
 
 
327
 
            
328
 
<li>Untokenized fields are best added directly to queries, and not
329
 
            through the query parser.  If a field's values are generated programmatically
330
 
            by the application, then so should query clauses for this field.
331
 
            An analyzer, which the query parser uses, is designed to convert human-entered
332
 
            text to terms.  Program-generated values, like dates, keywords, etc.,
333
 
            should be consistently program-generated.</li>
334
 
 
335
 
            
336
 
<li>In a query form, fields which are general text should use the query
337
 
            parser.  All others, such as date ranges, keywords, etc. are better added
338
 
            directly through the query API.  A field with a limit set of values,
339
 
            that can be specified with a pull-down menu should not be added to a
340
 
            query string which is subsequently parsed, but rather added as a
341
 
            TermQuery clause.</li>
342
 
            
343
 
</ol>
344
 
            
345
 
</p>
346
 
</div>
347
 
 
348
 
        
349
 
<a name="N10032"></a><a name="Terms"></a>
350
 
<h2 class="boxed">Terms</h2>
351
 
<div class="section">
352
 
<p>A query is broken up into terms and operators. There are two types of terms: Single Terms and Phrases.</p>
353
 
<p>A Single Term is a single word such as "test" or "hello".</p>
354
 
<p>A Phrase is a group of words surrounded by double quotes such as "hello dolly".</p>
355
 
<p>Multiple terms can be combined together with Boolean operators to form a more complex query (see below).</p>
356
 
<p>Note: The analyzer used to create the index will be used on the terms and phrases in the query string.
357
 
        So it is important to choose an analyzer that will not interfere with the terms used in the query string.</p>
358
 
</div>
359
 
 
360
 
        
361
 
<a name="N10048"></a><a name="Fields"></a>
362
 
<h2 class="boxed">Fields</h2>
363
 
<div class="section">
364
 
<p>Lucene supports fielded data. When performing a search you can either specify a field, or use the default field. The field names and default field is implementation specific.</p>
365
 
<p>You can search any field by typing the field name followed by a colon ":" and then the term you are looking for. </p>
366
 
<p>As an example, let's assume a Lucene index contains two fields, title and text and text is the default field.
367
 
        If you want to find the document entitled "The Right Way" which contains the text "don't go this way", you can enter: </p>
368
 
<pre class="code">title:"The Right Way" AND text:go</pre>
369
 
<p>or</p>
370
 
<pre class="code">title:"Do it right" AND right</pre>
371
 
<p>Since text is the default field, the field indicator is not required.</p>
372
 
<p>Note: The field is only valid for the term that it directly precedes, so the query</p>
373
 
<pre class="code">title:Do it right</pre>
374
 
<p>Will only find "Do" in the title field. It will find "it" and "right" in the default field (in this case the text field). </p>
375
 
</div>
376
 
 
377
 
        
378
 
<a name="N1006D"></a><a name="Term Modifiers"></a>
379
 
<h2 class="boxed">Term Modifiers</h2>
380
 
<div class="section">
381
 
<p>Lucene supports modifying query terms to provide a wide range of searching options.</p>
382
 
<a name="N10076"></a><a name="Wildcard Searches"></a>
383
 
<h3 class="boxed">Wildcard Searches</h3>
384
 
<p>Lucene supports single and multiple character wildcard searches within single terms
385
 
        (not within phrase queries).</p>
386
 
<p>To perform a single character wildcard search use the "?" symbol.</p>
387
 
<p>To perform a multiple character wildcard search use the "*" symbol.</p>
388
 
<p>The single character wildcard search looks for terms that match that with the single character replaced. For example, to search for "text" or "test" you can use the search:</p>
389
 
<pre class="code">te?t</pre>
390
 
<p>Multiple character wildcard searches looks for 0 or more characters. For example, to search for test, tests or tester, you can use the search: </p>
391
 
<pre class="code">test*</pre>
392
 
<p>You can also use the wildcard searches in the middle of a term.</p>
393
 
<pre class="code">te*t</pre>
394
 
<p>Note: You cannot use a * or ? symbol as the first character of a search.</p>
395
 
<a name="N1009B"></a><a name="Fuzzy Searches"></a>
396
 
<h3 class="boxed">Fuzzy Searches</h3>
397
 
<p>Lucene supports fuzzy searches based on the Levenshtein Distance, or Edit Distance algorithm. To do a fuzzy search use the tilde, "~", symbol at the end of a Single word Term. For example to search for a term similar in spelling to "roam" use the fuzzy search: </p>
398
 
<pre class="code">roam~</pre>
399
 
<p>This search will find terms like foam and roams.</p>
400
 
<p>Starting with Lucene 1.9 an additional (optional) parameter can specify the required similarity. The value is between 0 and 1, with a value closer to 1 only terms with a higher similarity will be matched. For example:</p>
401
 
<pre class="code">roam~0.8</pre>
402
 
<p>The default that is used if the parameter is not given is 0.5.</p>
403
 
<a name="N100B4"></a><a name="Proximity Searches"></a>
404
 
<h3 class="boxed">Proximity Searches</h3>
405
 
<p>Lucene supports finding words are a within a specific distance away. To do a proximity search use the tilde, "~", symbol at the end of a Phrase. For example to search for a "apache" and "jakarta" within 10 words of each other in a document use the search: </p>
406
 
<pre class="code">"jakarta apache"~10</pre>
407
 
<a name="N100C1"></a><a name="Range Searches"></a>
408
 
<h3 class="boxed">Range Searches</h3>
409
 
<p>Range Queries allow one to match documents whose field(s) values
410
 
            are between the lower and upper bound specified by the Range Query.
411
 
            Range Queries can be inclusive or exclusive of the upper and lower bounds.
412
 
            Sorting is done lexicographically.</p>
413
 
<pre class="code">mod_date:[20020101 TO 20030101]</pre>
414
 
<p>This will find documents whose mod_date fields have values between 20020101 and 20030101, inclusive.
415
 
            Note that Range Queries are not reserved for date fields.  You could also use range queries with non-date fields:</p>
416
 
<pre class="code">title:{Aida TO Carmen}</pre>
417
 
<p>This will find all documents whose titles are between Aida and Carmen, but not including Aida and Carmen.</p>
418
 
<p>Inclusive range queries are denoted by square brackets.  Exclusive range queries are denoted by
419
 
            curly brackets.</p>
420
 
<a name="N100DA"></a><a name="Boosting a Term"></a>
421
 
<h3 class="boxed">Boosting a Term</h3>
422
 
<p>Lucene provides the relevance level of matching documents based on the terms found. To boost a term use the caret, "^", symbol with a boost factor (a number) at the end of the term you are searching. The higher the boost factor, the more relevant the term will be.</p>
423
 
<p>Boosting allows you to control the relevance of a document by boosting its term. For example, if you are searching for</p>
424
 
<pre class="code">jakarta apache</pre>
425
 
<p>and you want the term "jakarta" to be more relevant boost it using the ^ symbol along with the boost factor next to the term.
426
 
        You would type:</p>
427
 
<pre class="code">jakarta^4 apache</pre>
428
 
<p>This will make documents with the term jakarta appear more relevant. You can also boost Phrase Terms as in the example: </p>
429
 
<pre class="code">"jakarta apache"^4 "Apache Lucene"</pre>
430
 
<p>By default, the boost factor is 1. Although the boost factor must be positive, it can be less than 1 (e.g. 0.2)</p>
431
 
</div>
432
 
 
433
 
 
434
 
        
435
 
<a name="N100FA"></a><a name="Boolean operators"></a>
436
 
<h2 class="boxed">Boolean Operators</h2>
437
 
<div class="section">
438
 
<p>Boolean operators allow terms to be combined through logic operators.
439
 
        Lucene supports AND, "+", OR, NOT and "-" as Boolean operators(Note: Boolean operators must be ALL CAPS).</p>
440
 
<a name="N10103"></a><a name="OR"></a>
441
 
<h3 class="boxed"></h3>
442
 
<p>The OR operator is the default conjunction operator. This means that if there is no Boolean operator between two terms, the OR operator is used.
443
 
        The OR operator links two terms and finds a matching document if either of the terms exist in a document. This is equivalent to a union using sets.
444
 
        The symbol || can be used in place of the word OR.</p>
445
 
<p>To search for documents that contain either "jakarta apache" or just "jakarta" use the query:</p>
446
 
<pre class="code">"jakarta apache" jakarta</pre>
447
 
<p>or</p>
448
 
<pre class="code">"jakarta apache" OR jakarta</pre>
449
 
<a name="N10116"></a><a name="AND"></a>
450
 
<h3 class="boxed">AND</h3>
451
 
<p>The AND operator matches documents where both terms exist anywhere in the text of a single document.
452
 
        This is equivalent to an intersection using sets. The symbol &amp;&amp; can be used in place of the word AND.</p>
453
 
<p>To search for documents that contain "jakarta apache" and "Apache Lucene" use the query: </p>
454
 
<pre class="code">"jakarta apache" AND "Apache Lucene"</pre>
455
 
<a name="N10126"></a><a name="+"></a>
456
 
<h3 class="boxed">+</h3>
457
 
<p>The "+" or required operator requires that the term after the "+" symbol exist somewhere in a the field of a single document.</p>
458
 
<p>To search for documents that must contain "jakarta" and may contain "lucene" use the query:</p>
459
 
<pre class="code">+jakarta lucene</pre>
460
 
<a name="N10136"></a><a name="NOT"></a>
461
 
<h3 class="boxed">NOT</h3>
462
 
<p>The NOT operator excludes documents that contain the term after NOT.
463
 
        This is equivalent to a difference using sets. The symbol ! can be used in place of the word NOT.</p>
464
 
<p>To search for documents that contain "jakarta apache" but not "Apache Lucene" use the query: </p>
465
 
<pre class="code">"jakarta apache" NOT "Apache Lucene"</pre>
466
 
<p>Note: The NOT operator cannot be used with just one term. For example, the following search will return no results:</p>
467
 
<pre class="code">NOT "jakarta apache"</pre>
468
 
<a name="N1014C"></a><a name="-"></a>
469
 
<h3 class="boxed">-</h3>
470
 
<p>The "-" or prohibit operator excludes documents that contain the term after the "-" symbol.</p>
471
 
<p>To search for documents that contain "jakarta apache" but not "Apache Lucene" use the query: </p>
472
 
<pre class="code">"jakarta apache" -"Apache Lucene"</pre>
473
 
</div>
474
 
 
475
 
        
476
 
<a name="N1015D"></a><a name="Grouping"></a>
477
 
<h2 class="boxed">Grouping</h2>
478
 
<div class="section">
479
 
<p>Lucene supports using parentheses to group clauses to form sub queries. This can be very useful if you want to control the boolean logic for a query.</p>
480
 
<p>To search for either "jakarta" or "apache" and "website" use the query:</p>
481
 
<pre class="code">(jakarta OR apache) AND website</pre>
482
 
<p>This eliminates any confusion and makes sure you that website must exist and either term jakarta or apache may exist.</p>
483
 
</div>
484
 
 
485
 
        
486
 
<a name="N10170"></a><a name="Field Grouping"></a>
487
 
<h2 class="boxed">Field Grouping</h2>
488
 
<div class="section">
489
 
<p>Lucene supports using parentheses to group multiple clauses to a single field.</p>
490
 
<p>To search for a title that contains both the word "return" and the phrase "pink panther" use the query:</p>
491
 
<pre class="code">title:(+return +"pink panther")</pre>
492
 
</div>
493
 
 
494
 
        
495
 
<a name="N10180"></a><a name="Escaping Special Characters"></a>
496
 
<h2 class="boxed">Escaping Special Characters</h2>
497
 
<div class="section">
498
 
<p>Lucene supports escaping special characters that are part of the query syntax. The current list special characters are</p>
499
 
<p>+ - &amp;&amp; || ! ( ) { } [ ] ^ " ~ * ? : \</p>
500
 
<p>To escape these character use the \ before the character. For example to search for (1+1):2 use the query:</p>
501
 
<pre class="code">\(1\+1\)\:2</pre>
502
 
</div>
503
 
 
504
 
   
505
 
</div>
506
 
<!--+
507
 
    |end content
508
 
    +-->
509
 
<div class="clearboth">&nbsp;</div>
510
 
</div>
511
 
<div id="footer">
512
 
<!--+
513
 
    |start bottomstrip
514
 
    +-->
515
 
<div class="lastmodified">
516
 
<script type="text/javascript"><!--
517
 
document.write("Last Published: " + document.lastModified);
518
 
//  --></script>
519
 
</div>
520
 
<div class="copyright">
521
 
        Copyright &copy;
522
 
         2006 <a href="http://www.apache.org/licenses/">The Apache Software Foundation.</a>
523
 
</div>
524
 
<!--+
525
 
    |end bottomstrip
526
 
    +-->
527
 
</div>
528
 
</body>
529
 
</html>