The search runs with the exact phrase is:
SELECT sc.id, sc.pagetitle, sc.longtitle, sc.description, sc.alias, sc.introtext, sc.template, sc.menutitle, sc.content, sc.publishedon
FROM `modx_site_content` sc
WHERE ((sc.published=1) AND (sc.searchable=1) AND (sc.deleted=0) AND (sc.privateweb=0))
GROUP BY sc.id
HAVING (((sc.content REGEXP '[[:<:]]Ernest Bell[[:>:]]') OR (sc.longtitle REGEXP '[[:<:]]Ernest Bell[[:>:]]')))
The exact phrase use the clause: sc.content REGEXP ’[[:<:]]Ernest Bell[[:>:]]’
As explained on this
page:
[[:<:]], [[:>:]]
These markers stand for word boundaries. They match the beginning and end of words, respectively. A word is a sequence of word characters that is not preceded by or followed by word characters. A word character is an alphanumeric character in the alnum class or an underscore (_).
So, in the extract "to hear of the death of Mr. Ernest Bell, so well-known for his humane work for animals", the term "ernest bell" is found as "Ernest Bell," because the comma is not considering as a word. Which is correct
But unfortunately when I set up the result, I use " ernest bell " (surrounded with a space character!) as search term so I can’t find "ernest bell" in the sentence: "to hear of the death of Mr. Ernest Bell, so well-known for his humane work for animals"
This issue is now registered as
AJAXSEARCH-72. To fix this issue do as follow:
1/ replace the line 168 of ajaxSearch/classes/ajaxSearchCtrl.class.php :
if ($advSearch == EXACTPHRASE) $searchList[] = " " . $search . " ";
by
if ($advSearch == EXACTPHRASE) $searchList[] = $search;
2/ replace the line 533 of ajaxSearch/classes/ajaxSearchResults.class.php :
$pattern = '/' . preg_quote($searchTerm, '/') . '/' . $pcreModifier;
by
if ($advSearch == EXACTPHRASE) $pattern = '/\b' . preg_quote($searchTerm, '/') . '\b/' . $pcreModifier;
else $pattern = '/' . preg_quote($searchTerm, '/') . '/' . $pcreModifier;
3/ replace the line 595 of ajaxSearch/classes/ajaxSearchResults.class.php :
$pattern = '/' . preg_quote($searchTerm, '/') . '/' . $pcreModifier;
by
if ($advSearch == EXACTPHRASE) $pattern = '/\b' . preg_quote($searchTerm, '/') . '\b/' . $pcreModifier;
else $pattern = '/' . preg_quote($searchTerm, '/') . '/' . $pcreModifier;
4/ replace the line 884 of ajaxSearch/classes/ajaxSearchResults.class.php :
$pattern = '/' . preg_quote($searchTerm, '/') . '/' . $pcreModifier;
by:
if ($advSearch == EXACTPHRASE) $pattern = '/\b' . preg_quote($searchTerm, '/') . '\b/' . $pcreModifier;
else $pattern = '/' . preg_quote($searchTerm, '/') . '/' . $pcreModifier;
Thanks for this feedback.