Implement search options to enable more performant queries#2752
Open
FabriceCastel wants to merge 1 commit intothoughtbot:mainfrom
Open
Implement search options to enable more performant queries#2752FabriceCastel wants to merge 1 commit intothoughtbot:mainfrom
FabriceCastel wants to merge 1 commit intothoughtbot:mainfrom
Conversation
shadoath
reviewed
Jan 16, 2025
shadoath
left a comment
There was a problem hiding this comment.
These are great additions for querying large datasets!
Member
|
Great, thanks for opening this! Could you make sure every change has a corresponding test? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Address issue: #2745
Change
Add the following config options to better control how administrate generates search queries targeting a given field:
search_exacttrue: the search will be performed using an equality comparisonfalse (default): the search will be performed using a substring search as... LIKE '%your-search-term%'search_lowertrue (default): search terms and target columns are lowercasedfalse: search terms and target columns retain their original casingThis change also introduces
search_requires_string_cast?onFieldclasses to avoid casting search columns withCAST(... AS CHAR(256))when the casting is redundant (ie. for string-like columns).The defaults for all of the above have been set so as to retain existing behaviour by default.
Usage/Rationale
search_exactallows users to support exact searches (for eg. an email address, a phone number, a postal code), in cases where substring matching isn't applicable and/or incurs too heavy a performance penalty on the db side when dealing with fairly large data setssearch_lowercontrols whether or not we lowercase the term and column being compared; this both adds support for case-sensitive searching as well as allows folks to disable theLOWER(...)clause in the generated query to avoid having to support it with extraneous db indices (eg. when searching for a phone number or zip code)