mirror of
https://github.com/standardebooks/web.git
synced 2025-07-23 07:44:49 -04:00
Remove apostrophes, don't preserve them
Searching by `UrlName`, now for both `Artwork` and `Artist`, is clearer. Take care to remove the apostrophes outright, don't replace them with a space because otherwise the letter after the apostrophe becomes its own term to match. Follow up to the fix for #461
This commit is contained in:
parent
bb7fe5d1ac
commit
5b5c75b2c8
1 changed files with 11 additions and 2 deletions
|
@ -1029,9 +1029,15 @@ class Artwork{
|
|||
$orderBy = 'art.CompletedYear desc';
|
||||
}
|
||||
|
||||
// Remove diacritics and non-alphanumeric characters, but preserve apostrophes.
|
||||
// Remove diacritics and non-alphanumeric characters.
|
||||
if($query !== null && $query != ''){
|
||||
$query = trim(preg_replace('|[^a-zA-Z0-9\'’ ]|ius', ' ', Formatter::RemoveDiacritics($query)));
|
||||
$query = Formatter::RemoveDiacritics($query);
|
||||
|
||||
// Remove apostrophes outright, don't replace with a space.
|
||||
$query = preg_replace('/[\'’]/u', '', $query);
|
||||
|
||||
// Replace all other non-alphanumeric characters with a space.
|
||||
$query = trim(preg_replace('|[^a-zA-Z0-9 ]|ius', ' ', $query));
|
||||
}
|
||||
else{
|
||||
$query = '';
|
||||
|
@ -1067,6 +1073,7 @@ class Artwork{
|
|||
$tokenizedQuery = '\b(' . implode('|', $tokenArray) . ')\b';
|
||||
|
||||
$params[] = $tokenizedQuery; // art.Name
|
||||
$params[] = $tokenizedQuery; // art.UrlName
|
||||
$params[] = $tokenizedQuery; // art.EbookUrl
|
||||
$params[] = $tokenizedQuery; // a.Name
|
||||
$params[] = $tokenizedQuery; // a.UrlName
|
||||
|
@ -1088,6 +1095,7 @@ class Artwork{
|
|||
where
|
||||
' . $statusCondition . '
|
||||
and (art.Name regexp ?
|
||||
or art.UrlName regexp ?
|
||||
or replace(art.EbookUrl, "_", " ") regexp ?
|
||||
or a.Name regexp ?
|
||||
or a.UrlName regexp ?
|
||||
|
@ -1107,6 +1115,7 @@ class Artwork{
|
|||
left join Tags t using (TagId)
|
||||
where ' . $statusCondition . '
|
||||
and (art.Name regexp ?
|
||||
or art.UrlName regexp ?
|
||||
or replace(art.EbookUrl, "_", " ") regexp ?
|
||||
or a.Name regexp ?
|
||||
or a.UrlName regexp ?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue