Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Hello,
first of all, thank you for this great module, simple to use and just neat !
I am not sure this is really a bug, but like said in the subject, the autocomplete will not give any result for words with upper-cases letters.
For exemple "Video" or "MOOC" won't return anything, when "video" or "mooc" will.
Maybe it is the way the module is designed, but it can be pretty disturbing especially when the user wants to search for a proper noun (like John or Paris).
Or maybe I missed something in the config ?
I thank you for your help or for any hints.
Comment | File | Size | Author |
---|---|---|---|
#25 | 2947273-25--fix-live-results-query-preprocessing.patch | 13.18 KB | drunken monkey |
|
Comments
Comment #2
Monkfish-FR CreditAttribution: Monkfish-FR commentedHi Clauce,
I had the same issue. I've resolved this with:
admin/config/search/search-api/index/<YOUR_INDEX>/processors
modules/contrib/search_api_autocomplete/src/Controller/AutocompleteController.php
at line 97, add this code:It transforms the search terms in lowercase. It's work for me.
If you need a patch, tell me!
Regards,
Comment #3
Clauce CreditAttribution: Clauce commentedFantastic, thanks, this is perfect, it saved my day.
I hope this will help improve the module development.
Comment #4
stephenrodrigo@yahoo.com CreditAttribution: stephenrodrigo@yahoo.com at Deloitte Digital for Deloitte Digital commentedIt's nice to have this as a patch @Monkfish-FR.
Comment #5
stephenrodrigo@yahoo.com CreditAttribution: stephenrodrigo@yahoo.com at Deloitte Digital for Deloitte Digital commentedComment #6
stephenrodrigo@yahoo.com CreditAttribution: stephenrodrigo@yahoo.com at Deloitte Digital for Deloitte Digital commentedComment #7
stephenrodrigo@yahoo.com CreditAttribution: stephenrodrigo@yahoo.com at Deloitte Digital for Deloitte Digital commentedComment #8
stephenrodrigo@yahoo.com CreditAttribution: stephenrodrigo@yahoo.com at Deloitte Digital for Deloitte Digital commentedComment #9
drunken monkeyWhich server backend are you using, or which suggester (in case it's not "Retrieve from server")?
Comment #10
stephenrodrigo@yahoo.com CreditAttribution: stephenrodrigo@yahoo.com at Deloitte Digital for Deloitte Digital commentedWe are using - Acquia search API.
Also, use `Display live results` suggester.
We have an use case that - Client wants `Display live results` style suggestions but not to link to the node.
Comment #11
adammaloneMinor nitpick with patch in #8. I'd probably look to include
\Drupal\Component\Utility\Unicode
at the top of the class and then use the following for consistency$keys = Unicode::strtolower($keys);
Comment #12
adammaloneComment #13
stephenrodrigo@yahoo.com CreditAttribution: stephenrodrigo@yahoo.com at Deloitte Digital for Deloitte Digital commentedThanks for the feedback. Updated the patch now.
Comment #14
stephenrodrigo@yahoo.com CreditAttribution: stephenrodrigo@yahoo.com at Deloitte Digital for Deloitte Digital commentedComment #17
drunken monkeyWith the "Display live results" suggester, the query should have the exact same preprocessing as for a normal search, so it should already be case-insensitive.
For the "Retrieve from server" suggester, the backend in question would have to decide whether or not to lowercase the search keys. We can't decide that for them, as it might not make sense (or be necessary) in all cases. If you're using the Acquia Search backend, please either move this issue there, or to the Search API Solr module in case the same problem exists there, too.
Comment #18
gge CreditAttribution: gge commentedHi,
Just applied #13 and everything is working as expected.
Without this patch "Display live results" suggester was not returning results if the entered word had first letter upper-case.
@drunken monkey here's a demo (simplytest.me) without patches, using "Display live results" suggester and also having "Ignore case" turned on. When searching "Apple" nothing shows up in the autocomplete but it does show the results when "apple" is entered.
Thank you!
Comment #19
drunken monkeyWhat backend are you using? If it’s the database backend, did you enable the “Ignore case” processor?
Comment #20
gge CreditAttribution: gge commented@drunken monkey yes I'm using the database as backend and "Ignore case" was also enabled. Sorry for this late reply, somehow I missed it...
Comment #21
mvogel CreditAttribution: mvogel commented@drunken monkey
it seems that the preprocessors maybe are forgotten for the live results.
I just added it like this, and everything is ok
Comment #22
drunken monkeyAh, you’re right, I see now what’s happening: In the controller we do preprocess the query before handing it over to the suggester(s), but in the
LiveResults
suggester plugin we only then set the full keywords – which therefore won’t be processed.The most reasonable fix here is probably to not preprocess prematurely in the controller, but only in plugins that need to do that explicitly (i.e., just
Server
, for the ones defined in this project).Patch attached, please test/review!
And thanks for providing more information!
Comment #23
drunken monkeyOops, forgot the patch file. Sorry!
Please test/review!
Comment #25
drunken monkeyThis should fix things.
Comment #26
drunken monkeyWould be great if someone could review the patch, or test whether it fixes the issue for them. Then I can commit.
Comment #27
mvogel CreditAttribution: mvogel commentedworks for me, thanks for the patch :)
Comment #29
drunken monkeyGood to hear, thanks for testing!
Committed.