|
|
@ -115,12 +115,14 @@ if ($config->webui->search->index->request->url->enabled && filter_var($q, FILTE |
|
|
|
// Extended corrections |
|
|
|
// Extended corrections |
|
|
|
switch (true) |
|
|
|
switch (true) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
// Empty query |
|
|
|
case empty($q): |
|
|
|
case empty($q): |
|
|
|
|
|
|
|
|
|
|
|
$query = $index->search('')->sort('RAND()'); |
|
|
|
$query = $index->search('')->sort('RAND()'); |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// URL request |
|
|
|
case filter_var($q, FILTER_VALIDATE_URL): |
|
|
|
case filter_var($q, FILTER_VALIDATE_URL): |
|
|
|
|
|
|
|
|
|
|
|
$query = $index->search('')->filter('id', crc32($q)); |
|
|
|
$query = $index->search('')->filter('id', crc32($q)); |
|
|
@ -136,42 +138,12 @@ switch (true) |
|
|
|
$query = $index->search($q); |
|
|
|
$query = $index->search($q); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Escape reserved chars |
|
|
|
// Regular request |
|
|
|
// http://sphinxsearch.com/docs/current/extended-syntax.html |
|
|
|
|
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Remove separator duplicates |
|
|
|
|
|
|
|
$q = trim( |
|
|
|
|
|
|
|
preg_replace( |
|
|
|
|
|
|
|
'/[\s]+/ui', |
|
|
|
|
|
|
|
' ', |
|
|
|
|
|
|
|
$q |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Escape special chars |
|
|
|
|
|
|
|
$request = @\Manticoresearch\Utils::escape( |
|
|
|
|
|
|
|
$q |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Explode search phrase |
|
|
|
|
|
|
|
$words = []; |
|
|
|
|
|
|
|
foreach ((array) explode(' ', $request) as $word) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$words[] = trim( |
|
|
|
|
|
|
|
$word |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Build combined query |
|
|
|
|
|
|
|
$query = $index->search( |
|
|
|
$query = $index->search( |
|
|
|
sprintf( |
|
|
|
@\Manticoresearch\Utils::escape( |
|
|
|
'"%s"|%s', |
|
|
|
$q |
|
|
|
$request, |
|
|
|
|
|
|
|
implode( |
|
|
|
|
|
|
|
'|', |
|
|
|
|
|
|
|
$words |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|