Browse Source

use native query builder

main
yggverse 8 months ago
parent
commit
f0b1c2cf40
  1. 38
      src/webui/search.php

38
src/webui/search.php

@ -115,12 +115,14 @@ if ($config->webui->search->index->request->url->enabled && filter_var($q, FILTE @@ -115,12 +115,14 @@ if ($config->webui->search->index->request->url->enabled && filter_var($q, FILTE
// Extended corrections
switch (true)
{
// Empty query
case empty($q):
$query = $index->search('')->sort('RAND()');
break;
// URL request
case filter_var($q, FILTER_VALIDATE_URL):
$query = $index->search('')->filter('id', crc32($q));
@ -136,42 +138,12 @@ switch (true) @@ -136,42 +138,12 @@ switch (true)
$query = $index->search($q);
}
// Escape reserved chars
// http://sphinxsearch.com/docs/current/extended-syntax.html
// Regular request
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(
sprintf(
'"%s"|%s',
$request,
implode(
'|',
$words
)
@\Manticoresearch\Utils::escape(
$q
)
);
}

Loading…
Cancel
Save