Compare commits

..

2 commits

Author SHA1 Message Date
rxu
acbaf8f51a
Merge 043c8ec386 into e85b25122a 2025-04-24 19:55:02 +02:00
rxu
043c8ec386
Merge branch 'ticket/16941' into ticket/16941-master 2025-04-24 23:59:21 +07:00

View file

@ -268,9 +268,47 @@ class fulltext_sphinx implements search_backend_interface
$this->sphinx->SetMatchMode(SPH_MATCH_ANY); $this->sphinx->SetMatchMode(SPH_MATCH_ANY);
} }
if (strlen($keywords) > 0) // Split words
$split_keywords = preg_replace('#([^\p{L}\p{N}\'*"()])#u', '$1$1', str_replace('\'\'', '\' \'', trim($keywords)));
$matches = array();
preg_match_all('#(?:[^\p{L}\p{N}*"()]|^)([+\-|]?(?:[\p{L}\p{N}*"()]+\'?)*[\p{L}\p{N}*"()])(?:[^\p{L}\p{N}*"()]|$)#u', $split_keywords, $matches);
$this->split_words = $matches[1];
if ($terms == 'any')
{ {
$this->search_query = str_replace('"', '"', $keywords); $this->search_query = '';
foreach ($this->split_words as $word)
{
if ((strpos($word, '+') === 0) || (strpos($word, '-') === 0) || (strpos($word, '|') === 0))
{
$word = substr($word, 1);
}
$this->search_query .= $word . ' ';
}
}
else
{
$this->search_query = '';
foreach ($this->split_words as $word)
{
if ((strpos($word, '+') === 0) || (strpos($word, '-') === 0))
{
$this->search_query .= $word . ' ';
}
else if (strpos($word, '|') === 0)
{
$this->search_query .= substr($word, 1) . ' ';
}
else
{
$this->search_query .= '+' . $word . ' ';
}
}
}
if ($this->search_query)
{
$this->search_query = str_replace('"', '"', $this->search_query);
return true; return true;
} }
@ -952,7 +990,7 @@ class fulltext_sphinx implements search_backend_interface
array('read_timeout', '5'), array('read_timeout', '5'),
array('max_children', '30'), array('max_children', '30'),
array('pid_file', $this->config['fulltext_sphinx_data_path'] . 'searchd.pid'), array('pid_file', $this->config['fulltext_sphinx_data_path'] . 'searchd.pid'),
array('binlog_path', rtrim($this->config['fulltext_sphinx_data_path'], '/\\')), // Trim trailing slash array('binlog_path', $this->config['fulltext_sphinx_data_path']),
), ),
); );