Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
I have a search index where all full text fields use the Ignore Case processor. This means that typing an upper case letter into an autocomplete field returns no results.
Proposed resolution
Add an option the the autocomplete config entity to make it case insensitive, and cast the string to lower case before sending the query.
Remaining tasks
Approve approach
Code
User interface changes
None.
API changes
None.
Data model changes
Add new field to config schema.
Comment | File | Size | Author |
---|---|---|---|
#5 | allow_case_insensitive_autocomplete-2890159-5.patch | 800 bytes | tarasich |
Comments
Comment #2
drunken monkeyWhat server backend are you using? I think all that I'm familiar with already implement this.
Comment #3
acbramley CreditAttribution: acbramley at PreviousNext commented@drunken monkey using SOLR 5.x, am I missing some config somewhere?
Comment #4
drunken monkeyNot very familiar with that module in D8. In any case, it belongs in their queue, then.
Comment #5
tarasichSearch API module had similar issue for DB backend: https://www.drupal.org/node/2231453
This patch is actually a copy/paste from that issue.
Comment #6
acbramley CreditAttribution: acbramley at PreviousNext commentedThanks @tarasich, works well!
Comment #7
mkalkbrennerDue to the fact that the DB backend already has a similar patch I would like to see this patch to be applied against Search API Autocomplete instead of all backends. Do you agree?
Comment #8
andypostMakes sense, looks no way to fix in one place
Comment #9
drunken monkeyNo, I don't agree. It's true that most backends will store indexed words in lowercase, to make searches case-insensitive, and that users will usually use the "Ignore case" processor where this isn't automatically done. However, this is in no way required behavior, so it's possible (or, almost certain) that this would break existing functionality in some (albeit few) cases. So, we could add this to the Autocomplete module, but we would definitely have to make it optional there.
Whereas the lowercasing of all indexed text (unless with custom schema overrides) is something not optional in the Solr backend, making the current behavior wrong no matter how you configure your search and index – the tokens in the Solr index will in any case be lowercase (weird phrasing …).
So, I think this could be a feature request for the Autocomplete module, but it's definitely a bug report for the Solr module and should be committed. (To be completely correct, I guess we'd have to also apply any other indexing filters enabled by default in our Solr schema, but that's more or less impossible (actually impossible, probably, for stemming) anyways, and lowercasing should already resolve most issues. Maybe also transliterate? I don't know.)
Comment #11
mkalkbrennerOk. Committed. Thanks :-)