Fix artifact search to use exact matching with optional wildcard support #6868
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.
Summary
Fixes #6298 - Artifact search now correctly performs exact matching by default, with optional wildcard support for flexible searching.
Problem
The artifact search API was incorrectly performing substring matching on all name queries. When searching for an artifact named
"name", the API would return artifacts like"name-test"because it always used SQLLIKE '%name%'pattern matching.Solution
Modified the search implementation to intelligently handle wildcards:
Exact match (no wildcards): Uses SQL
=operator for precise matching"name"→ Returns only artifacts named exactly"name"End wildcard: Uses SQL
LIKEwith%suffix for prefix matching"name*"→ Returns artifacts starting with"name"(e.g.,"name","name-test")Start wildcard: Uses SQL
LIKEwith%prefix for suffix matching"*name"→ Returns artifacts ending with"name"(e.g.,"name","test-name")Both wildcards: Uses SQL
LIKEwith%on both sides for contains matching"*name*"→ Returns all artifacts containing"name"Changes
AbstractSqlRegistryStorage.javato detect*wildcards in name filters and apply appropriate SQL operatorsArtifactSearchTest.javavalidating all matching patternsTesting
All test cases validate:
name*)*name)*name*)Backwards Compatibility
This is a breaking change for users who relied on the previous substring matching behavior. Users who want substring matching should now explicitly use wildcards (e.g.,
"*name*"instead of"name").