Changes for page Lucene Search Query Help
Last modified by Djebloun Sidali on 2014/02/23 15:55
Change comment:
Document converted from syntax xwiki/1.0 to syntax xwiki/2.1
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Syntax
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki 1.01 +XWiki 2.1 - Content
-
... ... @@ -1,13 +1,20 @@ 1 +{{velocity filter="none"}} 2 +{{html clean="false" wiki="true"}} 1 1 #startfloatingbox() 2 -*Contents* 3 -#toc ("2" "3" "") 4 +**Contents** 5 + 6 +{{toc start="2" depth="3" numbered=""/}} 4 4 #endfloatingbox() 8 +{{/html}} 9 +{{/velocity}} 5 5 6 - 1Lucene Search Query Help11 += Lucene Search Query Help = 7 7 8 -#info("Need more informations ? see the [lucene website>http://lucene.apache.org/java/docs/queryparsersyntax.html]") 13 +{{info}} 14 +Need more informations ? see the [[lucene website>>http://lucene.apache.org/java/docs/queryparsersyntax.html]] 15 +{{/info}} 9 9 10 - 1.1Terms17 +== Terms == 11 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,224 +14,237 @@ 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).") 24 +{{info}} 25 +Multiple terms can be combined together with Boolean operators to form a more complex query (see below). 26 +{{/info}} 18 18 19 - 1.1Wildcard Searches28 +== 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 " *" symbol.33 +* 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} 37 +{{code}} 29 29 te?t 30 -{code} 39 +{{/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} 43 +{{code}} 35 35 test* 36 -{code} 45 +{{/code}} 37 37 38 38 You can also use the wildcard searches in the middle of a term. 39 39 40 -{code} 49 +{{code}} 41 41 te*t 42 -{code} 51 +{{/code}} 43 43 44 -#warning("Note: You cannot use a * or ? symbol as the first character of a search.") 53 +{{warning}} 54 +Note: You cannot use a * or ? symbol as the first character of a search. 55 +{{/warning}} 45 45 46 - 1.1Boolean Operators57 +== Boolean Operators == 47 47 48 -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).59 +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} 65 +{{code}} 55 55 "jakarta apache" jakarta 56 -{code} 67 +{{/code}} 57 57 58 58 or 59 59 60 -{code} 71 +{{code}} 61 61 "jakarta apache" OR jakarta 62 -{code} 73 +{{/code}} 63 63 64 - 1.1.1AND75 +=== 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} 81 +{{code}} 71 71 "jakarta apache" AND "Apache Lucene" 72 -{code} 83 +{{/code}} 73 73 74 - 1.1.1+85 +=== + === 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} 91 +{{code}} 81 81 +jakarta lucene 82 -{code} 93 +{{/code}} 83 83 84 - 1.1.1NOT95 +=== 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} 101 +{{code}} 91 91 "jakarta apache" NOT "Apache Lucene" 92 -{code} 103 +{{/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} 107 +{{code}} 97 97 NOT "jakarta apache" 98 -{code} 109 +{{/code}} 99 99 100 - 1.1.1-111 +=== - === 101 101 102 -The " -" or prohibit operator excludes documents that contain the term after the "-" symbol.113 +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} 117 +{{code}} 107 107 "jakarta apache" -"Apache Lucene" 108 -{code} 119 +{{/code}} 109 109 110 - 1.1.1Grouping121 +=== 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} 127 +{{code}} 117 117 (jakarta OR apache) AND website 118 -{code} 129 +{{/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.1Field Grouping133 +=== 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} 139 +{{code}} 129 129 title:(+return +"pink panther") 130 -{code} 141 +{{/code}} 131 131 132 - 1.1Escaping Special Characters143 +== 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} 147 +{{code}} 137 137 + - && || ! ( ) { } [ ] ^ " ~ * ? : \ 138 -{code} 149 +{{/code}} 139 139 140 -To escape these character use the \before the character. For example to search for (1+1):2 use the query:151 +To escape these character use the before the character. For example to search for (1+1):2 use the query: 141 141 142 -{code} 153 +{{code}} 143 143 \(1\+1\)\:2 144 -{code} 155 +{{/code}} 145 145 146 - 1.1Searchable fields157 +== 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.1wiki161 +=== 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 167 +{{code}} 168 +test AND wiki:mywiki 169 +{{/code}} 160 160 171 +=== title === 172 + 161 161 Look for documents with title "Welcome to your wiki": 162 -{code} 174 + 175 +{{code}} 163 163 title:"Welcome to your wiki" 164 -{code} 177 +{{/code}} 165 165 166 - 1.1.1name179 +=== name === 167 167 168 168 Look for documents named "WebHome": 169 -{code} 182 + 183 +{{code}} 170 170 name:WebHome 171 -{code} 185 +{{/code}} 172 172 173 - 1.1.1lang187 +=== lang === 174 174 175 175 Look for "Voila" in french documents : 176 -{code} 190 + 191 +{{code}} 177 177 Voila AND lang:fr 178 -{code} 193 +{{/code}} 179 179 180 - 1.1.1type195 +=== 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} 200 + 201 +{{code}} 186 186 test AND type:attachment 187 -{code} 203 +{{/code}} 188 188 189 - 1.1.1filename205 +=== filename === 190 190 191 191 Look for attachments with a filename starting by "test": 192 -{code} 208 + 209 +{{code}} 193 193 filename:test* 194 -{code} 211 +{{/code}} 195 195 196 - 1.1.1object213 +=== 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} 218 + 219 +{{code}} 202 202 test AND object:XWiki.XWikiComments 203 -{code} 221 +{{/code}} 204 204 205 - 1.1.1author223 +=== author === 206 206 207 207 Look for documents last modified by XWiki.Admin: 208 -{code} 226 + 227 +{{code}} 209 209 author:XWiki.Admin 210 -{code} 229 +{{/code}} 211 211 212 - 1.1.1date231 +=== date === 213 213 214 214 Date format: yyyyMMddHHmm 215 215 216 216 Look for documents last modified on 2009/07/08: 217 -{code} 236 + 237 +{{code}} 218 218 date:20090708* 219 -{code} 239 +{{/code}} 220 220 221 - 1.1.1creator241 +=== creator === 222 222 223 223 Look for documents created by XWiki.Admin: 224 -{code} 244 + 245 +{{code}} 225 225 creator:XWiki.Admin 226 -{code} 247 +{{/code}} 227 227 228 - 1.1.1creationdate249 +=== 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 - 255 +{{code}} 256 +creationdate:20090708* 257 +{{/code}}