Skip to content
Snippets Groups Projects
Commit a46cb54c authored by Quentin Ribac's avatar Quentin Ribac
Browse files

FIX #18657 TIME 0:08 fulltext search: ignoring shorter words (<3 characters) and squeezing spaces

parent ea0ba9a0
No related branches found
No related tags found
No related merge requests found
......@@ -1228,6 +1228,15 @@ class SearchController
$matchingResources = [];
if (!empty($args['body']['fulltext']['values'])) {
// regex /\b[^"*~\s]{1,2}\b/
// \b: word boundary
// [^...]: reverse character class (captures only what is not ...)
// "*~: Zend Lucene Search meta characters
// \s: blank space
// {1,2}: 1 or 2 characters of this character class
// result: captures words of 1 or 2 characters that are not space, not counting Zend Lucene Search meta characters
$args['body']['fulltext']['values'] = preg_replace('/\b[^"*~\s]{1,2}\b/', '', $args['body']['fulltext']['values']);
$args['body']['fulltext']['values'] = preg_replace('/\s+/', ' ', $args['body']['fulltext']['values']); // squeezing spaces
if (strpos($args['body']['fulltext']['values'], "'") === false && ($args['body']['fulltext']['values'][0] != '"' || $args['body']['fulltext']['values'][strlen($args['body']['fulltext']['values']) - 1] != '"')) {
$query_fulltext = explode(" ", trim($args['body']['fulltext']['values']));
foreach ($query_fulltext as $key => $value) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment