Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search results different if you use uppercase vs lowercase #3315

Closed
Pixney-William opened this issue Mar 1, 2021 · 9 comments
Closed

Search results different if you use uppercase vs lowercase #3315

Pixney-William opened this issue Mar 1, 2021 · 9 comments
Labels

Comments

@Pixney-William
Copy link
Contributor

Bug Description

We have a client in Russia who has a website with English and Russian content.

When searching for : Киношкола which is the exact spelling as киношкола we get different search results.
Page titles that has Киношкола with the first letter in uppercase is found, but if you search for content with the first letter being in lowercase, no results are found.

How to Reproduce

Create a page with title :
Киношкола «Печенгафильм» в открытой студии «Арктик-ТВ» и радио «RECORD»

Then try search for it

Extra Detail

image

image

Environment

Statamic 3.0.45 Pro
Laravel 7.30.4
PHP 7.4.13
doublethreedigital/duplicator 1.2.3

Install method (choose one):

  • Fresh install from statamic/statamic
@jasonvarga
Copy link
Member

As a workaround, I would suggest using Algolia. https://statamic.dev/search#algolia

Case doesn't seem to matter when using the English alphabet.

@jasonvarga
Copy link
Member

I took a quick look - adding u modifiers to these regexes seems to fix it, but I don't know what other effects that would have.

'whole' => '#^'.$escaped_chunk.'$#i',
'partial' => '#'.$escaped_chunk.'#i',
'partial_from_start' => '#^'.$escaped_chunk.'#i',

@Pixney-William
Copy link
Contributor Author

Thanks. The project budget is kind of an issue for Algolia implementation. But i guess in a worst case scenario it is something i have to go with.

I'll try to find if there are any solutions out there and get back.

@Pixney-William
Copy link
Contributor Author

Also, i guess Algolia would work for the front end as a solution. But it would not work as a solution for search within the CMS admin area.

@jasonvarga
Copy link
Member

Algolia has a free tier.
You can use it for the CP search. I wouldn't have suggested it otherwise.

@Pixney-William
Copy link
Contributor Author

Ah, if it works for the cp then maybe thats a workaround.

@jeremyvienney
Copy link

@Pixney-William I get a workaround with customizing the search index.
You could add a transformers array https://statamic.dev/search#transforming-fields, for exemple I used this with lowercase and stripping accents to handle all situations :

use CodeInc\StripAccents\StripAccents;
...
...
'title' => function ($title) {
                    if ($title) {
                        $name2Search = $title . ' ' . StripAccents::strip($title) . ' ' .strtolower(StripAccents::strip($title));
                    }
                    return $title ? $name2Search : false;
                },

@jonassiewertsen
Copy link
Contributor

We are running into the same issue.

Searching for Økotopen does return results, but økotopen does not return any.

@ryanmitchell
Copy link
Contributor

This should have been fixed by #11363

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants