Show last authors
1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
4
5 {{info}}
6 Need more informations? See the [[lucene website>>http://lucene.apache.org/java/docs/index.html]]. More specifically look for the "Query Syntax" documentation entry for the Lucene Core version matching the version used in your XWiki installation (to find the version used by XWiki look for ##lucene-core-x.y.z.jar## in the XWiki's ##/WEB-INF/lib## folder. For example for XWiki Enterprise 2.6 uses Lucene Core 2.9.3 which means the Lucene Query Syntax can be found [[here>>http://lucene.apache.org/java/2_9_3/queryparsersyntax.html]].
7 {{/info}}
8
9 = Terms =
10
11 A query is broken up into terms and operators. There are two types of terms: Single Terms and Phrases.
12
13 * A Single Term is a single word such as "test" or "hello".
14 * A Phrase is a group of words surrounded by double quotes such as "hello dolly".
15
16 {{info}}
17 Multiple terms can be combined together with Boolean operators to form a more complex query (see below).
18 {{/info}}
19
20 = Wildcard Searches =
21
22 Lucene supports single and multiple character wildcard searches within single terms (not within phrase queries).
23
24 * To perform a single character wildcard search use the "?" symbol.
25 * To perform a multiple character wildcard search use the "*" symbol.
26
27 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:
28
29 {{code}}
30 te?t
31 {{/code}}
32
33 Multiple character wildcard searches looks for 0 or more characters. For example, to search for test, tests or tester, you can use the search:
34
35 {{code}}
36 test*
37 {{/code}}
38
39 You can also use the wildcard searches in the middle of a term.
40
41 {{code}}
42 te*t
43 {{/code}}
44
45 {{warning}}
46 Note: You cannot use a * or ? symbol as the first character of a search.
47 {{/warning}}
48
49 = Boolean Operators =
50
51 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).
52
53 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.
54
55 To search for documents that contain either "jakarta apache" or just "jakarta" use the query:
56
57 {{code}}
58 "jakarta apache" jakarta
59 {{/code}}
60
61 or
62
63 {{code}}
64 "jakarta apache" OR jakarta
65 {{/code}}
66
67 == AND ==
68
69 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.
70
71 To search for documents that contain "jakarta apache" and "Apache Lucene" use the query:
72
73 {{code}}
74 "jakarta apache" AND "Apache Lucene"
75 {{/code}}
76
77 == + ==
78
79 The "+" or required operator requires that the term after the "+" symbol exist somewhere in a the field of a single document.
80
81 To search for documents that must contain "jakarta" and may contain "lucene" use the query:
82
83 {{code}}
84 +jakarta lucene
85 {{/code}}
86
87 == NOT ==
88
89 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.
90
91 To search for documents that contain "jakarta apache" but not "Apache Lucene" use the query:
92
93 {{code}}
94 "jakarta apache" NOT "Apache Lucene"
95 {{/code}}
96
97 Note: The NOT operator cannot be used with just one term. For example, the following search will return no results:
98
99 {{code}}
100 NOT "jakarta apache"
101 {{/code}}
102
103 == - ==
104
105 The "-" or prohibit operator excludes documents that contain the term after the "-" symbol.
106
107 To search for documents that contain "jakarta apache" but not "Apache Lucene" use the query:
108
109 {{code}}
110 "jakarta apache" -"Apache Lucene"
111 {{/code}}
112
113 == Grouping ==
114
115 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.
116
117 To search for either "jakarta" or "apache" and "website" use the query:
118
119 {{code}}
120 (jakarta OR apache) AND website
121 {{/code}}
122
123 This eliminates any confusion and makes sure you that website must exist and either term jakarta or apache may exist.
124
125 == Field Grouping ==
126
127 Lucene supports using parentheses to group multiple clauses to a single field.
128
129 To search for a title that contains both the word "return" and the phrase "pink panther" use the query:
130
131 {{code}}
132 title:(+return +"pink panther")
133 {{/code}}
134
135 = Escaping Special Characters =
136
137 Lucene supports escaping special characters that are part of the query syntax. The current list special characters are
138
139 {{code}}
140 + - && || ! ( ) { } [ ] ^ " ~ * ? : \
141 {{/code}}
142
143 To escape these character use "\" (backslash) before the character. For example to search for (1+1):2 use the query:
144
145 {{code}}
146 \(1\+1\)\:2
147 {{/code}}
148
149 = Searchable fields =
150
151 XWiki documents contain wiki content and meta-information. Lucene indexes such information in fields.
152
153 == wiki ==
154
155 In a wiki farm you can specify a wiki to search in with the "wiki:" prefix.
156
157 Look for the word "test" in the wiki "mywiki":
158
159 {{code}}
160 test AND wiki:mywiki
161 {{/code}}
162
163 == title ==
164
165 Look for documents with title "Welcome to your wiki":
166
167 {{code}}
168 title:"Welcome to your wiki"
169 {{/code}}
170
171 == name ==
172
173 Look for documents named "WebHome":
174
175 {{code}}
176 name:WebHome
177 {{/code}}
178
179 == lang ==
180
181 Look for "Voila" in french documents :
182
183 {{code}}
184 Voila AND lang:fr
185 {{/code}}
186
187 == type ==
188
189 Type of a document: "attachment", "wikipage" or "objects", used to control presentation of searchresults.
190
191 Look for "test" in attachments:
192
193 {{code}}
194 test AND type:attachment
195 {{/code}}
196
197 Look for "test" in pages but exclude attachments containing the word test:
198
199 {{code}}
200 test AND -type:attachment
201 {{/code}}
202
203 == filename ==
204
205 Look for attachments with a filename starting with "test":
206
207 {{code}}
208 filename:test*
209 {{/code}}
210
211 == mimetype ==
212
213 Look for attachments with a certain MIME type. Examples:
214
215 * Search for PDFs only: {{code language="none"}}mimetype:application/pdf{{/code}}
216 * Search for all attachments except images: {{code language="none"}}type:attachment -mimetype:image/*{{/code}}
217
218 == object ==
219
220 The "object:" prefix allow to search for pages containing objects from a specific class.
221
222 Look for comments containing the word "test":
223
224 {{code}}
225 test AND object:XWiki.XWikiComments
226 {{/code}}
227
228 == author ==
229
230 Look for documents last modified by XWiki.Admin:
231
232 {{code}}
233 author:XWiki.Admin
234 {{/code}}
235
236 == date ==
237
238 Date format: yyyyMMddHHmm
239
240 Look for documents last modified on 2009/07/08:
241
242 {{code}}
243 date:20090708*
244 {{/code}}
245
246 == creator ==
247
248 Look for documents created by XWiki.Admin:
249
250 {{code}}
251 creator:XWiki.Admin
252 {{/code}}
253
254 == creationdate ==
255
256 Date format: yyyyMMddHHmm
257
258 Look for documents created on 2009/07/08:
259
260 {{code}}
261 creationdate:20090708*
262 {{/code}}
263
264 == Searching for fields in XWiki objects ==
265
266 Beside Lucene's XWiki specific index fields, querying for documents based on the property values of contained XWiki objects is also possible.
267
268 Look for the profile page of a user who's first name is 'Administrator'.
269
270 {{code}}
271 XWiki.XWikiUsers.first_name:'Administrator'
272 {{/code}}
273
274 Look for all users or groups, except the group template:
275
276 {{code}}
277 +(object:XWiki.XWikiUsers object:XWiki.XWikiGroups) -name:XWikiGroupTemplate
278 {{/code}}
279
280 Looking for documents by a value which is stored in a DatabaseTree property in an object. As a mention, the searched value can be wrapped inside round paranthesis or single / double quotes
281
282 {{code}}
283 +Space.Class.databaseTreeProperty:(searchedValue)
284 {{/code}}
285
286 If you would like to add a logical disjunction to the above use case, you can do it like this:
287
288 {{code}}
289 +Space.Class.databaseTreeProperty:(searchedValue OR anotherSearchedValue)
290 {{/code}}
291
292 This will return all documents which contain in the object's property value either searchedValue or anotherSearchedValue

Get Connected