From 20eb59c0f9e20ad262338d545a887f11b7066b40 Mon Sep 17 00:00:00 2001 From: Remi Dettai Date: Tue, 23 Dec 2025 17:11:34 +0100 Subject: [PATCH 1/2] Add test showing the problem --- .../scenarii/qw_search_api/0001_ts_range.yaml | 6 ++++++ .../scenarii/qw_search_api/_setup.quickwit.yaml | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/quickwit/rest-api-tests/scenarii/qw_search_api/0001_ts_range.yaml b/quickwit/rest-api-tests/scenarii/qw_search_api/0001_ts_range.yaml index 8c42620ca55..dc9765b634e 100644 --- a/quickwit/rest-api-tests/scenarii/qw_search_api/0001_ts_range.yaml +++ b/quickwit/rest-api-tests/scenarii/qw_search_api/0001_ts_range.yaml @@ -34,3 +34,9 @@ params: query: "ts:>=1684993002 AND ts:<1684993004" expected: num_hits: 2 +--- +endpoint: simple/search +params: + query: "auto_date:>=2023-05-25T00:00:00Z AND auto_date:<2023-05-26T00:00:00Z" +expected: + num_hits: 2 diff --git a/quickwit/rest-api-tests/scenarii/qw_search_api/_setup.quickwit.yaml b/quickwit/rest-api-tests/scenarii/qw_search_api/_setup.quickwit.yaml index 51bb6bf2b7a..b333ed3c86a 100644 --- a/quickwit/rest-api-tests/scenarii/qw_search_api/_setup.quickwit.yaml +++ b/quickwit/rest-api-tests/scenarii/qw_search_api/_setup.quickwit.yaml @@ -30,8 +30,8 @@ endpoint: simple/ingest params: commit: force ndjson: - - {"ts": 1684993001, "not_fast": 1684993001} - - {"ts": 1684993002, "not_fast": 1684993002} + - {"ts": 1684993001, "not_fast": 1684993001, "auto_date": "2023-05-25T10:00:00Z"} + - {"ts": 1684993002, "not_fast": 1684993002, "auto_date": "2023-05-25T11:00:00Z"} --- # Ingest documents split #2 method: POST From 9b96542536117e84e9133b8d3bd3e3382f5ca9f6 Mon Sep 17 00:00:00 2001 From: Remi Dettai Date: Tue, 6 Jan 2026 11:09:20 +0100 Subject: [PATCH 2/2] Add datetime filter to range query --- .../src/query_ast/range_query.rs | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/quickwit/quickwit-query/src/query_ast/range_query.rs b/quickwit/quickwit-query/src/query_ast/range_query.rs index 8ec42f999d2..3f5c4471ae4 100644 --- a/quickwit/quickwit-query/src/query_ast/range_query.rs +++ b/quickwit/quickwit-query/src/query_ast/range_query.rs @@ -216,7 +216,11 @@ impl BuildTantivyAst for RangeQuery { } else if let Some(range) = bounds_range_f64 { sub_queries.push(query_from_fast_val_range(&empty_term, range).into()); } - + let bounds_range_date: Option<(Bound, Bound)> = + convert_bound(&self.lower_bound).zip(convert_bound(&self.upper_bound)); + if let Some(range) = bounds_range_date { + sub_queries.push(query_from_fast_val_range(&empty_term, range).into()); + } let mut normalizer = options .get_fast_field_tokenizer_name() @@ -404,6 +408,34 @@ mod tests { ); } + #[test] + fn test_range_dynamic_datetime() { + let range_query = RangeQuery { + field: "hello".to_string(), + lower_bound: Bound::Included(JsonLiteral::String( + "2020-12-09T16:09:53+00:00".to_string(), + )), + upper_bound: Bound::Included(JsonLiteral::String( + "2020-12-09T16:09:53+00:00".to_string(), + )), + }; + let schema = make_schema(true); + let tantivy_ast = range_query + .build_tantivy_ast_call(&BuildTantivyAstContext::for_test(&schema)) + .unwrap(); + assert_eq!( + format!("{tantivy_ast:?}"), + "Bool(TantivyBoolQuery { must: [], must_not: [], should: [Leaf(FastFieldRangeQuery { \ + bounds: BoundsRange { lower_bound: Included(Term(field=6, type=Json, path=hello, \ + type=Date, 2020-12-09T16:09:53Z)), upper_bound: Included(Term(field=6, type=Json, \ + path=hello, type=Date, 2020-12-09T16:09:53Z)) } }), Leaf(FastFieldRangeQuery { \ + bounds: BoundsRange { lower_bound: Included(Term(field=6, type=Json, path=hello, \ + type=Str, \"2020-12-09T16:09:53+00:00\")), upper_bound: Included(Term(field=6, \ + type=Json, path=hello, type=Str, \"2020-12-09T16:09:53+00:00\")) } })], filter: [], \ + minimum_should_match: None })" + ); + } + #[test] fn test_range_query_not_fast_field() { let range_query = RangeQuery {