Changes for page Lucene Search Query Help

Last modified by Djebloun Sidali on 2014/02/23 15:55

<
From version < 1.2 >
edited by Vincent Massol
on 2010/12/08 19:40
To version < 5.1 >
edited by Vincent Massol
on 2010/12/08 19:45
>
Change comment: There is no comment for this version

Summary

Details

Page properties
Title
... ... @@ -1,1 +1,1 @@
1 -Search Application Query Syntax
1 + Lucene Search Query Help
Parent
... ... @@ -1,1 +1,1 @@
1 -Extension.WebHome
1 +Extension.Search Application
Syntax
... ... @@ -1,1 +1,1 @@
1 -XWiki 1.0
1 +XWiki 2.1
Content
... ... @@ -1,237 +1,247 @@
1 -#startfloatingbox()
2 -*Contents*
3 -#toc ("2" "3" "")
4 -#endfloatingbox()
1 +{{box cssClass="floatinginfobox" title="**Contents**"}}{{toc/}}{{/box}}
5 5  
6 -1 Lucene Search Query Help
3 +{{info}}
4 +Need more informations ? see the [[lucene website>>http://lucene.apache.org/java/docs/queryparsersyntax.html]]
5 +{{/info}}
7 7  
8 -#info("Need more informations ? see the [lucene website>http://lucene.apache.org/java/docs/queryparsersyntax.html]")
7 += Terms =
9 9  
10 -1.1 Terms
11 -
12 12  A query is broken up into terms and operators. There are two types of terms: Single Terms and Phrases.
13 13  
14 14  * A Single Term is a single word such as "test" or "hello".
15 15  * A Phrase is a group of words surrounded by double quotes such as "hello dolly".
16 16  
17 -#info("Multiple terms can be combined together with Boolean operators to form a more complex query (see below).")
14 +{{info}}
15 +Multiple terms can be combined together with Boolean operators to form a more complex query (see below).
16 +{{/info}}
18 18  
19 -1.1 Wildcard Searches
18 += Wildcard Searches =
20 20  
21 21  Lucene supports single and multiple character wildcard searches within single terms (not within phrase queries).
22 22  
23 23  * To perform a single character wildcard search use the "?" symbol.
24 -* To perform a multiple character wildcard search use the "&#42;" symbol.
23 +* To perform a multiple character wildcard search use the "*" symbol.
25 25  
26 26  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:
27 27  
28 -{code}
27 +{{code}}
29 29  te?t
30 -{code}
29 +{{/code}}
31 31  
32 32  Multiple character wildcard searches looks for 0 or more characters. For example, to search for test, tests or tester, you can use the search:
33 33  
34 -{code}
33 +{{code}}
35 35  test*
36 -{code}
35 +{{/code}}
37 37  
38 38  You can also use the wildcard searches in the middle of a term.
39 39  
40 -{code}
39 +{{code}}
41 41  te*t
42 -{code}
41 +{{/code}}
43 43  
44 -#warning("Note: You cannot use a &#42; or ? symbol as the first character of a search.")
43 +{{warning}}
44 +Note: You cannot use a * or ? symbol as the first character of a search.
45 +{{/warning}}
45 45  
46 -1.1 Boolean Operators
47 += Boolean Operators =
47 47  
48 -Boolean operators allow terms to be combined through logic operators. Lucene supports AND, "+", OR, NOT and "&#45;" as Boolean operators(Note: Boolean operators must be ALL CAPS).
49 +Boolean operators allow terms to be combined through logic operators. Lucene supports AND, "+", OR, NOT and "-" as Boolean operators(Note: Boolean operators must be ALL CAPS).
49 49  
50 50  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. 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. The symbol || can be used in place of the word OR.
51 51  
52 52  To search for documents that contain either "jakarta apache" or just "jakarta" use the query:
53 53  
54 -{code}
55 +{{code}}
55 55  "jakarta apache" jakarta
56 -{code}
57 +{{/code}}
57 57  
58 58  or
59 59  
60 -{code}
61 +{{code}}
61 61  "jakarta apache" OR jakarta
62 -{code}
63 +{{/code}}
63 63  
64 -1.1.1 AND
65 +== AND ==
65 65  
66 66  The AND operator matches documents where both terms exist anywhere in the text of a single document. This is equivalent to an intersection using sets. The symbol && can be used in place of the word AND.
67 67  
68 68  To search for documents that contain "jakarta apache" and "Apache Lucene" use the query:
69 69  
70 -{code}
71 +{{code}}
71 71  "jakarta apache" AND "Apache Lucene"
72 -{code}
73 +{{/code}}
73 73  
74 -1.1.1 +
75 +== + ==
75 75  
76 76  The "+" or required operator requires that the term after the "+" symbol exist somewhere in a the field of a single document.
77 77  
78 78  To search for documents that must contain "jakarta" and may contain "lucene" use the query:
79 79  
80 -{code}
81 +{{code}}
81 81  +jakarta lucene
82 -{code}
83 +{{/code}}
83 83  
84 -1.1.1 NOT
85 +== NOT ==
85 85  
86 86  The NOT operator excludes documents that contain the term after NOT. This is equivalent to a difference using sets. The symbol ! can be used in place of the word NOT.
87 87  
88 88  To search for documents that contain "jakarta apache" but not "Apache Lucene" use the query:
89 89  
90 -{code}
91 +{{code}}
91 91  "jakarta apache" NOT "Apache Lucene"
92 -{code}
93 +{{/code}}
93 93  
94 94  Note: The NOT operator cannot be used with just one term. For example, the following search will return no results:
95 95  
96 -{code}
97 +{{code}}
97 97  NOT "jakarta apache"
98 -{code}
99 +{{/code}}
99 99  
100 -1.1.1 &#45;
101 +== - ==
101 101  
102 -The "&#45;" or prohibit operator excludes documents that contain the term after the "&#45;" symbol.
103 +The "-" or prohibit operator excludes documents that contain the term after the "-" symbol.
103 103  
104 104  To search for documents that contain "jakarta apache" but not "Apache Lucene" use the query:
105 105  
106 -{code}
107 +{{code}}
107 107  "jakarta apache" &#45;"Apache Lucene"
108 -{code}
109 +{{/code}}
109 109  
110 -1.1.1 Grouping
111 +== Grouping ==
111 111  
112 112  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.
113 113  
114 114  To search for either "jakarta" or "apache" and "website" use the query:
115 115  
116 -{code}
117 +{{code}}
117 117  (jakarta OR apache) AND website
118 -{code}
119 +{{/code}}
119 119  
120 120  This eliminates any confusion and makes sure you that website must exist and either term jakarta or apache may exist.
121 121  
122 -1.1.1 Field Grouping
123 +== Field Grouping ==
123 123  
124 124  Lucene supports using parentheses to group multiple clauses to a single field.
125 125  
126 126  To search for a title that contains both the word "return" and the phrase "pink panther" use the query:
127 127  
128 -{code}
129 +{{code}}
129 129  title:(+return +"pink panther")
130 -{code}
131 +{{/code}}
131 131  
132 -1.1 Escaping Special Characters
133 += Escaping Special Characters =
133 133  
134 134  Lucene supports escaping special characters that are part of the query syntax. The current list special characters are
135 135  
136 -{code}
137 +{{code}}
137 137  + - && || ! ( ) { } [ ] ^ " ~ * ? : \
138 -{code}
139 +{{/code}}
139 139  
140 -To escape these character use the \ before the character. For example to search for (1+1):2 use the query:
141 +To escape these character use the before the character. For example to search for (1+1):2 use the query:
141 141  
142 -{code}
143 +{{code}}
143 143  \(1\+1\)\:2
144 -{code}
145 +{{/code}}
145 145  
146 -1.1 Searchable fields
147 += Searchable fields =
147 147  
148 148  XWiki documents contain wiki content and meta-information, lucene indexes such information in fields.
149 149  
150 -1.1.1 wiki
151 +== wiki ==
151 151  
152 152  In a wiki farm you can specify a wiki to search in with the "wiki:" prefix.
153 153  
154 154  Look for the word "test" in the wiki "mywiki":
155 -{code}
156 -test AND wiki:mywiki
157 -{code}
158 158  
159 -1.1.1 title
157 +{{code}}
158 +test AND wiki:mywiki
159 +{{/code}}
160 160  
161 +== title ==
162 +
161 161  Look for documents with title "Welcome to your wiki":
162 -{code}
164 +
165 +{{code}}
163 163  title:"Welcome to your wiki"
164 -{code}
167 +{{/code}}
165 165  
166 -1.1.1 name
169 +== name ==
167 167  
168 168  Look for documents named "WebHome":
169 -{code}
172 +
173 +{{code}}
170 170  name:WebHome
171 -{code}
175 +{{/code}}
172 172  
173 -1.1.1 lang
177 +== lang ==
174 174  
175 175  Look for "Voila" in french documents :
176 -{code}
180 +
181 +{{code}}
177 177  Voila AND lang:fr
178 -{code}
183 +{{/code}}
179 179  
180 -1.1.1 type
185 +== type ==
181 181  
182 182  Type of a document: "attachment", "wikipage" or "objects", used to control presentation of searchresults.
183 183  
184 184  Look for "test" in attachments :
185 -{code}
190 +
191 +{{code}}
186 186  test AND type:attachment
187 -{code}
193 +{{/code}}
188 188  
189 -1.1.1 filename
195 +== filename ==
190 190  
191 191  Look for attachments with a filename starting by "test":
192 -{code}
198 +
199 +{{code}}
193 193  filename:test*
194 -{code}
201 +{{/code}}
195 195  
196 -1.1.1 object
203 +== object ==
197 197  
198 198  The "object:" prefix allow to search for pages containing objects from a specific class.
199 199  
200 200  Look for comments containing the word "test":
201 -{code}
208 +
209 +{{code}}
202 202  test AND object:XWiki.XWikiComments
203 -{code}
211 +{{/code}}
204 204  
205 -1.1.1 author
213 +== author ==
206 206  
207 207  Look for documents last modified by XWiki.Admin:
208 -{code}
216 +
217 +{{code}}
209 209  author:XWiki.Admin
210 -{code}
219 +{{/code}}
211 211  
212 -1.1.1 date
221 +== date ==
213 213  
214 214  Date format: yyyyMMddHHmm
215 215  
216 216  Look for documents last modified on 2009/07/08:
217 -{code}
226 +
227 +{{code}}
218 218  date:20090708*
219 -{code}
229 +{{/code}}
220 220  
221 -1.1.1 creator
231 +== creator ==
222 222  
223 223  Look for documents created by XWiki.Admin:
224 -{code}
234 +
235 +{{code}}
225 225  creator:XWiki.Admin
226 -{code}
237 +{{/code}}
227 227  
228 -1.1.1 creationdate
239 +== creationdate ==
229 229  
230 230  Date format: yyyyMMddHHmm
231 231  
232 232  Look for documents created on 2009/07/08:
233 -{code}
234 -creationdate:20090708*
235 -{code}
236 236  
237 -
245 +{{code}}
246 +creationdate:20090708*
247 +{{/code}}

Get Connected