From d3da6b8a5a5bd34a7129111a2b1cbceff10d53ab Mon Sep 17 00:00:00 2001 From: Vladimir Kuznichenkov Date: Sun, 29 Sep 2024 11:25:24 +0300 Subject: [PATCH] Add additional test to cover initially reported issue This test covers that we actually can call ES API endpoint with named alias as a formatter. https://github.com/quickwit-oss/quickwit/issues/5460 --- .../src/elastic_query_dsl/range_query.rs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/quickwit/quickwit-query/src/elastic_query_dsl/range_query.rs b/quickwit/quickwit-query/src/elastic_query_dsl/range_query.rs index a53c48bdb1f..337ec019e9d 100644 --- a/quickwit/quickwit-query/src/elastic_query_dsl/range_query.rs +++ b/quickwit/quickwit-query/src/elastic_query_dsl/range_query.rs @@ -142,4 +142,30 @@ mod tests { if field == "date" && lower_bound == JsonLiteral::String("2021-01-03T13:32:43Z".to_string()) )); } + + #[test] + fn test_date_range_query_with_strict_date_optional_time_format() { + let range_query_params = ElasticRangeQueryParams { + gt: None, + gte: None, + lt: None, + lte: Some(JsonLiteral::String("2024-09-28T10:22:55.797Z".to_string())), + boost: None, + format: JsonLiteral::String("strict_date_optional_time".to_string()).into(), + }; + let range_query: ElasticRangeQuery = ElasticRangeQuery { + field: "timestamp".to_string(), + value: range_query_params, + }; + let range_query_ast = range_query.convert_to_query_ast().unwrap(); + assert!(matches!( + range_query_ast, + QueryAst::Range(RangeQuery { + field, + lower_bound: Bound::Unbounded, + upper_bound: Bound::Included(upper_bound), + }) + if field == "timestamp" && upper_bound == JsonLiteral::String("2024-09-28T10:22:55.797Z".to_string()) + )); + } }