mirror of
https://github.com/YGGverse/Yo.git
synced 2026-03-31 09:45:30 +00:00
build combined search query
This commit is contained in:
parent
1c2e8dafb2
commit
d6b5f8b210
1 changed files with 30 additions and 1 deletions
|
|
@ -140,8 +140,37 @@ switch (true)
|
|||
// http://sphinxsearch.com/docs/current/extended-syntax.html
|
||||
else
|
||||
{
|
||||
// Escape special chars
|
||||
$q = @\Manticoresearch\Utils::escape(
|
||||
$q
|
||||
);
|
||||
|
||||
// Remove separator duplicates
|
||||
$q = preg_replace(
|
||||
'/[\s]+/ui',
|
||||
' ',
|
||||
$q
|
||||
);
|
||||
|
||||
// Explode search phrase
|
||||
$words = [];
|
||||
foreach ((array) explode(' ', $q) as $word)
|
||||
{
|
||||
$words[] = trim(
|
||||
$word
|
||||
);
|
||||
}
|
||||
|
||||
// Build combined query
|
||||
$query = $index->search(
|
||||
@\Manticoresearch\Utils::escape($q)
|
||||
sprintf(
|
||||
'"%s"|%s',
|
||||
$q,
|
||||
implode(
|
||||
'|',
|
||||
$words
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue