From version < 1.2 >
edited by Vincent Massol
on 2010/12/08 19:40
To version < 3.1 >
edited by Vincent Massol
on 2010/12/08 19:44
< >
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
Syntax
... ... @@ -1,1 +1,1 @@
1 -XWiki 1.0
1 +XWiki 2.1
Content
... ... @@ -1,236 +1,249 @@
1 -#startfloatingbox()
2 -*Contents*
3 -#toc ("2" "3" "")
4 -#endfloatingbox()
1 + {{box cssClass="floatinginfobox" title="**Contents**"}}
2 +{{toc/}}
3 +{{/box}}
5 5  
6 -1 Lucene Search Query Help
5 +{{info}}
6 +Need more informations ? see the [[lucene website>>http://lucene.apache.org/java/docs/queryparsersyntax.html]]
7 +{{/info}}
7 7  
8 -#info("Need more informations ? see the [lucene website>http://lucene.apache.org/java/docs/queryparsersyntax.html]")
9 += 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).")
16 +{{info}}
17 +Multiple terms can be combined together with Boolean operators to form a more complex query (see below).
18 +{{/info}}
18 18  
19 -1.1 Wildcard Searches
20 += 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.
25 +* 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}
29 +{{code}}
29 29  te?t
30 -{code}
31 +{{/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}
35 +{{code}}
35 35  test*
36 -{code}
37 +{{/code}}
37 37  
38 38  You can also use the wildcard searches in the middle of a term.
39 39  
40 -{code}
41 +{{code}}
41 41  te*t
42 -{code}
43 +{{/code}}
43 43  
44 -#warning("Note: You cannot use a &#42; or ? symbol as the first character of a search.")
45 +{{warning}}
46 +Note: You cannot use a * or ? symbol as the first character of a search.
47 +{{/warning}}
45 45  
46 -1.1 Boolean Operators
49 += 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).
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).
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}
57 +{{code}}
55 55  "jakarta apache" jakarta
56 -{code}
59 +{{/code}}
57 57  
58 58  or
59 59  
60 -{code}
63 +{{code}}
61 61  "jakarta apache" OR jakarta
62 -{code}
65 +{{/code}}
63 63  
64 -1.1.1 AND
67 +== 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}
73 +{{code}}
71 71  "jakarta apache" AND "Apache Lucene"
72 -{code}
75 +{{/code}}
73 73  
74 -1.1.1 +
77 +== + ==
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}
83 +{{code}}
81 81  +jakarta lucene
82 -{code}
85 +{{/code}}
83 83  
84 -1.1.1 NOT
87 +== 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}
93 +{{code}}
91 91  "jakarta apache" NOT "Apache Lucene"
92 -{code}
95 +{{/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}
99 +{{code}}
97 97  NOT "jakarta apache"
98 -{code}
101 +{{/code}}
99 99  
100 -1.1.1 &#45;
103 +== - ==
101 101  
102 -The "&#45;" or prohibit operator excludes documents that contain the term after the "&#45;" symbol.
105 +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}
109 +{{code}}
107 107  "jakarta apache" &#45;"Apache Lucene"
108 -{code}
111 +{{/code}}
109 109  
110 -1.1.1 Grouping
113 +== 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}
119 +{{code}}
117 117  (jakarta OR apache) AND website
118 -{code}
121 +{{/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
125 +== 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}
131 +{{code}}
129 129  title:(+return +"pink panther")
130 -{code}
133 +{{/code}}
131 131  
132 -1.1 Escaping Special Characters
135 += 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}
139 +{{code}}
137 137  + - && || ! ( ) { } [ ] ^ " ~ * ? : \
138 -{code}
141 +{{/code}}
139 139  
140 -To escape these character use the \ before the character. For example to search for (1+1):2 use the query:
143 +To escape these character use the before the character. For example to search for (1+1):2 use the query:
141 141  
142 -{code}
145 +{{code}}
143 143  \(1\+1\)\:2
144 -{code}
147 +{{/code}}
145 145  
146 -1.1 Searchable fields
149 += 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
153 +== 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
159 +{{code}}
160 +test AND wiki:mywiki
161 +{{/code}}
160 160  
163 +== title ==
164 +
161 161  Look for documents with title "Welcome to your wiki":
162 -{code}
166 +
167 +{{code}}
163 163  title:"Welcome to your wiki"
164 -{code}
169 +{{/code}}
165 165  
166 -1.1.1 name
171 +== name ==
167 167  
168 168  Look for documents named "WebHome":
169 -{code}
174 +
175 +{{code}}
170 170  name:WebHome
171 -{code}
177 +{{/code}}
172 172  
173 -1.1.1 lang
179 +== lang ==
174 174  
175 175  Look for "Voila" in french documents :
176 -{code}
182 +
183 +{{code}}
177 177  Voila AND lang:fr
178 -{code}
185 +{{/code}}
179 179  
180 -1.1.1 type
187 +== 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}
192 +
193 +{{code}}
186 186  test AND type:attachment
187 -{code}
195 +{{/code}}
188 188  
189 -1.1.1 filename
197 +== filename ==
190 190  
191 191  Look for attachments with a filename starting by "test":
192 -{code}
200 +
201 +{{code}}
193 193  filename:test*
194 -{code}
203 +{{/code}}
195 195  
196 -1.1.1 object
205 +== 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}
210 +
211 +{{code}}
202 202  test AND object:XWiki.XWikiComments
203 -{code}
213 +{{/code}}
204 204  
205 -1.1.1 author
215 +== author ==
206 206  
207 207  Look for documents last modified by XWiki.Admin:
208 -{code}
218 +
219 +{{code}}
209 209  author:XWiki.Admin
210 -{code}
221 +{{/code}}
211 211  
212 -1.1.1 date
223 +== date ==
213 213  
214 214  Date format: yyyyMMddHHmm
215 215  
216 216  Look for documents last modified on 2009/07/08:
217 -{code}
228 +
229 +{{code}}
218 218  date:20090708*
219 -{code}
231 +{{/code}}
220 220  
221 -1.1.1 creator
233 +== creator ==
222 222  
223 223  Look for documents created by XWiki.Admin:
224 -{code}
236 +
237 +{{code}}
225 225  creator:XWiki.Admin
226 -{code}
239 +{{/code}}
227 227  
228 -1.1.1 creationdate
241 +== 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  
247 +{{code}}
248 +creationdate:20090708*
249 +{{/code}}

Get Connected