mirror of
https://github.com/YGGverse/YGGo.git
synced 2025-01-12 07:48:34 +00:00
update Filter::searchQuery method
This commit is contained in:
parent
cc0cca346b
commit
48e0482dbd
@ -91,8 +91,18 @@ class Filter {
|
|||||||
|
|
||||||
$query = trim($query);
|
$query = trim($query);
|
||||||
|
|
||||||
// Quote reserved keyword operators
|
// Return short or empty queries
|
||||||
|
if (mb_strlen($query) <= 1) {
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lowercase query to deactivate reserved operators
|
||||||
|
$query = mb_strtolower($query);
|
||||||
|
|
||||||
|
// Quote other operators
|
||||||
$operators = [
|
$operators = [
|
||||||
|
/* lowercased
|
||||||
'MAYBE',
|
'MAYBE',
|
||||||
'AND',
|
'AND',
|
||||||
'OR',
|
'OR',
|
||||||
@ -102,8 +112,8 @@ class Filter {
|
|||||||
'ZONE',
|
'ZONE',
|
||||||
'ZONESPAN',
|
'ZONESPAN',
|
||||||
'PARAGRAPH',
|
'PARAGRAPH',
|
||||||
|
*/
|
||||||
'\\', '/', '~', '@', '!', '"', '(', ')', '[', ']', '|', '?', '%', '-', '>', '<', ':', ';', '^', '$'
|
'\\', '/', '~', '@', '!', '"', "'", '(', ')', '[', ']', '|', '?', '%', '-', '>', '<', ':', ';', '^', '$'
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($operators as $operator) {
|
foreach ($operators as $operator) {
|
||||||
@ -131,13 +141,13 @@ class Filter {
|
|||||||
|
|
||||||
if (mb_strlen($word) > 1) {
|
if (mb_strlen($word) > 1) {
|
||||||
|
|
||||||
$words[] = sprintf('%s*', $word);
|
$words[] = sprintf('(%s*)', $word);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = sprintf('@title %s | "%s" | %s', $query,
|
$query = sprintf('@title %s | "%s" | (%s)', $query,
|
||||||
$crc32query,
|
$crc32query,
|
||||||
implode(' | ', $words));
|
implode(' | ', $words));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user