Lucene query parser.
More...
◆ __construct()
ilLuceneQueryParser::__construct |
( |
|
$a_query_string | ) |
|
◆ checkAllowedCharacters()
static ilLuceneQueryParser::checkAllowedCharacters |
( |
string |
$query | ) |
|
|
staticprotected |
Check allowed characters.
- Exceptions
-
Definition at line 114 of file class.ilLuceneQueryParser.php.
114 : bool
115 {
116 if (preg_match('/[^\pL0-9_+\-:.()\"*?&§€|!{}\[\]\^~\\@#\/$%\'= ]/u', $query) != 0) {
118 }
119 return true;
120 }
◆ checkAmpersands()
static ilLuceneQueryParser::checkAmpersands |
( |
string |
$query | ) |
|
|
staticprotected |
Check ampersands.
- Exceptions
-
Definition at line 138 of file class.ilLuceneQueryParser.php.
138 : bool
139 {
140 if (preg_match('/[&]{2}/', $query) > 0) {
141 if (preg_match('/^([\pL0-9_+\-:.()\"*?&|!{}\[\]\^~\\@#\/$%\'=]+( && )?[\pL0-9_+\-:.()\"*?|!{}\[\]\^~\\@#\/$%\'=]+[ ]*)+$/u', $query) == 0) {
143 }
144 }
145 return true;
146 }
◆ checkANDORNOT()
static ilLuceneQueryParser::checkANDORNOT |
( |
string |
$a_query | ) |
|
|
staticprotected |
Check AND OR NOT.
- Exceptions
-
Definition at line 254 of file class.ilLuceneQueryParser.php.
254 : bool
255 {
256 if (preg_match('/^([\pL0-9_+\-:.()\"*?&|!{}\[\]\^~\\@\/#$%\'=]+\s*((AND )|(OR )|(AND NOT )|(NOT ))?[\pL0-9_+\-:.()\"*?&|!{}\[\]\^~\\@\/#$%\'=]+[ ]*)+$/u', $a_query) == 0) {
258 }
259 return true;
260 }
◆ checkAsterisk()
static ilLuceneQueryParser::checkAsterisk |
( |
string |
$query | ) |
|
|
staticprotected |
Check asterisk.
- Exceptions
-
Definition at line 126 of file class.ilLuceneQueryParser.php.
126 : bool
127 {
128 if (preg_match('/^[\*]*$|[\s]\*|^\*[^\s]/', $query) != 0) {
130 }
131 return true;
132 }
◆ checkCaret()
static ilLuceneQueryParser::checkCaret |
( |
string |
$query | ) |
|
|
staticprotected |
Check carets.
- Exceptions
-
Definition at line 152 of file class.ilLuceneQueryParser.php.
152 : bool
153 {
154 if (preg_match('/[^\\\]\^([^\s]*[^0-9.]+)|[^\\\]\^$/', $query) != 0) {
156 }
157 return true;
158 }
Referenced by validateQuery().
◆ checkColon()
static ilLuceneQueryParser::checkColon |
( |
string |
$a_query | ) |
|
|
staticprotected |
Check colon.
- Exceptions
-
Definition at line 290 of file class.ilLuceneQueryParser.php.
290 : bool
291 {
292 if (preg_match('/[^\\\\s]:[\s]|[^\\\\s]:$|[\s][^\\]?:|^[^\\\\s]?:/', $a_query) != 0) {
294 }
295 return true;
296 }
◆ checkExclamationMark()
static ilLuceneQueryParser::checkExclamationMark |
( |
string |
$query | ) |
|
|
staticprotected |
Check exclamation marks (replacement for NOT)
- Exceptions
-
Definition at line 176 of file class.ilLuceneQueryParser.php.
176 : bool
177 {
178 if (preg_match('/^[^!]*$|^([\pL0-9_+\-:.()\"*?&|!{}\[\]\^~\\@#\/$%\'=]+( ! )?[\pL0-9_+\-:.()\"*?&|!{}\[\]\^~\\@#\/$%\'=]+[ ]*)+$/u', $query, $matches) == 0) {
180 }
181 return true;
182 }
◆ checkParenthesis()
static ilLuceneQueryParser::checkParenthesis |
( |
string |
$a_query | ) |
|
|
staticprotected |
Check parenthesis.
- Exceptions
-
Definition at line 200 of file class.ilLuceneQueryParser.php.
200 : bool
201 {
202 $hasLft = false;
203 $hasRgt = false;
204
205 $matchLft = 0;
206 $matchRgt = 0;
207
208 $tmp = array();
209
210 if (($matchLft = preg_match_all('/[(]/', $a_query, $tmp)) > 0) {
211 $hasLft = true;
212 }
213 if (($matchRgt = preg_match_all('/[)]/', $a_query, $tmp)) > 0) {
214 $hasRgt = true;
215 }
216
217 if (!$hasLft || !$hasRgt) {
218 return true;
219 }
220
221
222 if (($hasLft && !$hasRgt) || ($hasRgt && !$hasLft)) {
224 }
225
226 if ($matchLft !== $matchRgt) {
228 }
229
230 if (preg_match('/\(\s*\)/', $a_query) > 0) {
232 }
233 return true;
234 }
Referenced by validateQuery().
◆ checkPlusMinus()
static ilLuceneQueryParser::checkPlusMinus |
( |
string |
$a_query | ) |
|
|
staticprotected |
Check plus minus.
- Exceptions
-
Definition at line 241 of file class.ilLuceneQueryParser.php.
241 : bool
242 {
243 if (preg_match('/^[^\n+\-]*$|^([+-]?\s*[\pL0-9_:.()\"*?&|!{}\[\]\^~\\@#\/$%\'=]+[ ]?)+$/u', $a_query) == 0) {
245 }
246 return true;
247 }
◆ checkQuestionMark()
static ilLuceneQueryParser::checkQuestionMark |
( |
string |
$query | ) |
|
|
staticprotected |
Check question mark (wild card single character)
- Exceptions
-
Definition at line 188 of file class.ilLuceneQueryParser.php.
188 : bool
189 {
190 if (preg_match('/^(\?)|([^\pL0-9_+\-:.()\"*?&|!{}\[\]\^~\\@#\/$%\'=]\?+)/u', $query, $matches) != 0) {
192 }
193 return true;
194 }
◆ checkQuotes()
static ilLuceneQueryParser::checkQuotes |
( |
string |
$a_query | ) |
|
|
staticprotected |
Check quotes.
- Exceptions
-
Definition at line 267 of file class.ilLuceneQueryParser.php.
267 : bool
268 {
269 $matches = preg_match_all('/"/', $a_query, $tmp);
270
271 if ($matches == 0) {
272 return true;
273 }
274
275 if (($matches % 2) > 0) {
277 }
278
279 if (preg_match('/"\s*"/', $a_query) > 0) {
281 }
282 return true;
283 }
Referenced by validateQuery().
◆ checkSquiggle()
static ilLuceneQueryParser::checkSquiggle |
( |
string |
$query | ) |
|
|
staticprotected |
Check squiggles.
- Exceptions
-
Definition at line 164 of file class.ilLuceneQueryParser.php.
164 : bool
165 {
166 if (preg_match('/[^\\\]*~[^\s]*[^0-9\s]+/', $query, $matches) != 0) {
168 }
169 return true;
170 }
Referenced by validateQuery().
◆ getQuery()
ilLuceneQueryParser::getQuery |
( |
| ) |
|
◆ parse()
ilLuceneQueryParser::parse |
( |
| ) |
|
◆ parseAutoWildcard()
ilLuceneQueryParser::parseAutoWildcard |
( |
| ) |
|
Append asterisk for remote search from global search form field.
Definition at line 59 of file class.ilLuceneQueryParser.php.
59 : void
60 {
61 $this->parsed_query = trim($this->query_string);
62 if (stristr($this->parsed_query, '*')) {
63 return;
64 }
65 if (substr($this->parsed_query, -1) !== '"') {
66 $this->parsed_query .= '*';
67 }
68 }
◆ replaceOwnerCallback()
ilLuceneQueryParser::replaceOwnerCallback |
( |
array |
$matches | ) |
|
|
protected |
Replace owner callback (preg_replace_callback)
Definition at line 78 of file class.ilLuceneQueryParser.php.
78 : string
79 {
80 if (isset($matches[2])) {
82 return $matches[1] . $usr_id;
83 }
84 }
85 return $matches[0];
86 }
static _loginExists(string $a_login, int $a_user_id=0)
References ilObjUser\_loginExists().
◆ validateQuery()
static ilLuceneQueryParser::validateQuery |
( |
|
$a_query | ) |
|
|
static |
◆ $parsed_query
string ilLuceneQueryParser::$parsed_query = '' |
|
protected |
◆ $query_string
string ilLuceneQueryParser::$query_string |
|
protected |
The documentation for this class was generated from the following file: