Numeric Ranges with RangeFilter
Numeric Ranges with RangeFilter
~12 Min. Lesezeit Zuletzt aktualisiert am August 8, 2026
SearchFilter (chapter 31) checks for a MATCH, NOT for GREATER/LESS THAN – for numeric ranges like priority, RangeFilter is the right tool.
Applying RangeFilter
use ApiPlatform\Doctrine\Orm\Filter\RangeFilter;
#[ApiFilter(RangeFilter::class, properties: ['priority'])]
The operators at a glance
| Query parameter | Meaning |
|---|---|
priority[gt]=3 | priority GREATER than 3 |
priority[gte]=3 | priority GREATER THAN OR EQUAL to 3 |
priority[lt]=3 | priority LESS THAN 3 |
priority[lte]=3 | priority LESS THAN OR EQUAL to 3 |
priority[between]=2..4 | priority BETWEEN 2 and 4 (both INCLUSIVE) |
Querying a range
curl -k 'https://localhost/api/projects?priority[between]=2..4'between uses TWO values, SEPARATED by TWO dots (..) – MORE READABLE than two separate gte/lte parameters, but EQUIVALENT in content.
curl -k 'https://localhost/api/projects?priority[gte]=2&priority[lte]=4'This SECOND notation returns the SAME result as between – BOTH variants work IN PARALLEL and can be chosen depending on frontend needs.
Combining with sorting
curl -k 'https://localhost/api/projects?priority[gte]=4&order[priority]=asc'All HIGH-PRIORITY projects (priority ≥ 4), sorted ascending BY priority – EXACTLY the use case for a React dashboard (block 10) that should display filtered "urgent projects".
Tipp: RangeFilter ALSO works on DateTimeImmutable fields like createdAt – chapter 34 shows the SPECIALIZED DateFilter for that, with an even MORE CONVENIENT, date-specific syntax.