Skip to content

feat(doctrine): per-property filter map in FreeTextQueryFilter#8257

Open
soyuka wants to merge 1 commit into
api-platform:mainfrom
soyuka:feat/free-text-query-filter-per-property
Open

feat(doctrine): per-property filter map in FreeTextQueryFilter#8257
soyuka wants to merge 1 commit into
api-platform:mainfrom
soyuka:feat/free-text-query-filter-per-property

Conversation

@soyuka
Copy link
Copy Markdown
Member

@soyuka soyuka commented Jun 6, 2026

Q A
Branch? main
Bug fix? no
New feature? yes
Deprecations? no
Issues Refs #8249
License MIT

Summary

Extend FreeTextQueryFilter (ORM + ODM) to accept either:

  • a single FilterInterface — current behaviour, applied to every property;
  • an array<string, FilterInterface> map — a dedicated filter applied per property.

The map form solves cases where a single filter can't fit every property — e.g. PostgreSQL native uuid columns break LOWER(uuid) emitted by PartialSearchFilter, while ExactFilter works fine on them.

'q' => new QueryParameter(filter: new FreeTextQueryFilter([
    'name' => new OrFilter(new PartialSearchFilter()),
    'uuid' => new OrFilter(new ExactFilter()),
]), description: 'Partial name match or exact uuid match'),

Single-filter signature is preserved, so the change is non-breaking.

When the map form is used, the iterated properties default to the map keys; the $properties constructor arg still takes precedence if set.

Test plan

  • new functional test testFreeTextQueryFilterWithPerPropertyFilterMap covers partial-name vs exact-ean differentiation
  • all 7 FreeTextQueryFilterTest cases pass on ORM
  • ODM mirror executed in CI

Accept `array<string, FilterInterface>` for `FreeTextQueryFilter::$filter`
so a different filter can apply per property (e.g. partial search on
`name`, exact match on `uuid`). Single-filter form unchanged — BC-safe.

When the map form is used, the iterated properties default to the map
keys; the existing `$properties` arg still wins when set.

Refs api-platform#8249
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.

2 participants