Skip to content

Conversation

@EricWittmann
Copy link
Member

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 SQL LIKE '%name%' pattern matching.

Solution

Modified the search implementation to intelligently handle wildcards:

  • Exact match (no wildcards): Uses SQL = operator for precise matching

    • Search for "name" → Returns only artifacts named exactly "name"
  • End wildcard: Uses SQL LIKE with % suffix for prefix matching

    • Search for "name*" → Returns artifacts starting with "name" (e.g., "name", "name-test")
  • Start wildcard: Uses SQL LIKE with % prefix for suffix matching

    • Search for "*name" → Returns artifacts ending with "name" (e.g., "name", "test-name")
  • Both wildcards: Uses SQL LIKE with % on both sides for contains matching

    • Search for "*name*" → Returns all artifacts containing "name"

Changes

  • Modified AbstractSqlRegistryStorage.java to detect * wildcards in name filters and apply appropriate SQL operators
  • Added comprehensive test coverage with 7 test cases in ArtifactSearchTest.java validating all matching patterns

Testing

All test cases validate:

  • Exact matching returns only precisely matched artifacts
  • Prefix wildcard matching (name*)
  • Suffix wildcard matching (*name)
  • Contains wildcard matching (*name*)
  • Edge cases like non-existent names

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").

… wildcards

This commit fixes issue #6298 where artifact name searches incorrectly
performed substring matching on all queries. The previous implementation
always used SQL LIKE with wildcards (%), causing searches for "name" to
incorrectly return artifacts like "name-test".

Changes:
- Modified AbstractSqlRegistryStorage to detect wildcard characters (*) in
  name search queries
- Exact match (no wildcards): Uses SQL = operator for precise matching
  Example: "name" returns only artifacts named exactly "name"
- End wildcard: Uses SQL LIKE with % suffix for prefix matching
  Example: "name*" returns artifacts starting with "name"
- Start wildcard: Uses SQL LIKE with % prefix for suffix matching
  Example: "*name" returns artifacts ending with "name"
- Both wildcards: Uses SQL LIKE with % on both sides for contains matching
  Example: "*name*" returns artifacts containing "name"

- Added comprehensive test coverage in ArtifactSearchTest with 7 test cases
  validating exact matching and all wildcard patterns

Fixes #6298
@EricWittmann EricWittmann merged commit bdb9a14 into main Nov 13, 2025
18 checks passed
@EricWittmann EricWittmann deleted the issue-6298-artifact-search-name-matching branch November 13, 2025 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Artifact search returns incorrect artifacts

2 participants