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