Skip to content

Support gt, ge, lt and le filters on date fields - #98

Open
danielgreen wants to merge 1 commit into
feature23:mainfrom
danielgreen:fix/date-range-filters
Open

danielgreen wants to merge 1 commit into
feature23:mainfrom
danielgreen:fix/date-range-filters

Conversation

@danielgreen

@danielgreen danielgreen commented Oct 21, 2026 •

Copy link
Copy Markdown

Fixes #101

What was wrong

A range filter on an Edm.DateTimeOffset field returned 400:

POST /indexes/{index}/docs/search
{ "search": "*", "filter": "effective_date ge 2025-01-01T00:00:00Z" }

400: Greater than or equal comparison not supported for type DateTimeOffset

Only eq worked on dates. gt, ge, lt and le all failed.

What changed

Dates are indexed as Unix milliseconds. Each range handler in ODataQueryVisitor now has a date case that compares on that value, as the eq handler already does.

Tests

DateRangeFilterTests (new, 6 tests): each operator against a document dated exactly on the boundary, so the tests show which operators include it; the same instant written with another offset; and a closed range. All 6 fail without the change. All 979 unit tests pass.

Not covered: a comparison with the value first (2025-01-01T00:00:00Z lt effective_date) fails for every field type, not only dates. That is a separate gap.

dotnet test from the repo root currently stops before any test runs, on main too: restoring AzureSearchEmulator.Aspire fails with NU1902, a moderate advisory for MessagePack 2.5.302 (GHSA-qhrr-8q5h-9q3h) that the project treats as an error. I ran the unit and integration test projects directly.

A range filter on an Edm.DateTimeOffset field, such as
"Updated ge 2025-01-01T00:00:00Z", returned 400 with "comparison not
supported for type DateTimeOffset". Only eq worked.

Dates are indexed as Unix milliseconds, so each range handler now
compares on that, as the eq handler already does.
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.

Range filters (gt, ge, lt, le) on Edm.DateTimeOffset fields return 400

1 participant