mirror of
https://github.com/standardebooks/web.git
synced 2025-07-06 14:50:39 -04:00
Remove non-alphanumerics (except quotes) from search query
That is, don't replace non-alphanumerics with a space. This matches the behavior of Formatter::RemoveDiacriticsAndNonalphanumerics(), which would be used here except that function would also remove quotes. We actually discussed not introducing spaces previously, but I made a mistake and didn't apply the same change to the user's search query: https://github.com/standardebooks/web/pull/470#discussion_r1929591492 This change fixes queries with compound words like: `Haycraft-Queen` and also fixes queries for authors with apostrophes: `O'Neill` No changes to existing DBs are necessary because they already have terms like `haycraftqueen` and `oneill` stored in `IndexableCollections` and `IndexableAuthors`.
This commit is contained in:
parent
dab857d127
commit
8a4da08a66
1 changed files with 1 additions and 1 deletions
|
@ -2333,7 +2333,7 @@ final class Ebook{
|
||||||
|
|
||||||
if($query !== null && $query != ''){
|
if($query !== null && $query != ''){
|
||||||
// Preserve quotes in the query so the user can enter, e.g., "war and peace" for an exact match.
|
// Preserve quotes in the query so the user can enter, e.g., "war and peace" for an exact match.
|
||||||
$query = trim(preg_replace('|[^a-zA-Z0-9" ]|ius', ' ', Formatter::RemoveDiacritics($query)));
|
$query = trim(preg_replace('|[^a-zA-Z0-9" ]|ius', '', Formatter::RemoveDiacritics($query)));
|
||||||
|
|
||||||
$whereCondition .= ' and match(e.IndexableText, e.Title, e.IndexableAuthors, e.IndexableCollections) against(?) ';
|
$whereCondition .= ' and match(e.IndexableText, e.Title, e.IndexableAuthors, e.IndexableCollections) against(?) ';
|
||||||
$params[] = $query;
|
$params[] = $query;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue