@@ -216,7 +216,11 @@ impl BuildTantivyAst for RangeQuery {
216216 } else if let Some ( range) = bounds_range_f64 {
217217 sub_queries. push ( query_from_fast_val_range ( & empty_term, range) . into ( ) ) ;
218218 }
219-
219+ let bounds_range_date: Option < ( Bound < DateTime > , Bound < DateTime > ) > =
220+ convert_bound ( & self . lower_bound ) . zip ( convert_bound ( & self . upper_bound ) ) ;
221+ if let Some ( range) = bounds_range_date {
222+ sub_queries. push ( query_from_fast_val_range ( & empty_term, range) . into ( ) ) ;
223+ }
220224 let mut normalizer =
221225 options
222226 . get_fast_field_tokenizer_name ( )
@@ -404,6 +408,34 @@ mod tests {
404408 ) ;
405409 }
406410
411+ #[ test]
412+ fn test_range_dynamic_datetime ( ) {
413+ let range_query = RangeQuery {
414+ field : "hello" . to_string ( ) ,
415+ lower_bound : Bound :: Included ( JsonLiteral :: String (
416+ "2020-12-09T16:09:53+00:00" . to_string ( ) ,
417+ ) ) ,
418+ upper_bound : Bound :: Included ( JsonLiteral :: String (
419+ "2020-12-09T16:09:53+00:00" . to_string ( ) ,
420+ ) ) ,
421+ } ;
422+ let schema = make_schema ( true ) ;
423+ let tantivy_ast = range_query
424+ . build_tantivy_ast_call ( & BuildTantivyAstContext :: for_test ( & schema) )
425+ . unwrap ( ) ;
426+ assert_eq ! (
427+ format!( "{tantivy_ast:?}" ) ,
428+ "Bool(TantivyBoolQuery { must: [], must_not: [], should: [Leaf(FastFieldRangeQuery { \
429+ bounds: BoundsRange { lower_bound: Included(Term(field=6, type=Json, path=hello, \
430+ type=Date, 2020-12-09T16:09:53Z)), upper_bound: Included(Term(field=6, type=Json, \
431+ path=hello, type=Date, 2020-12-09T16:09:53Z)) } }), Leaf(FastFieldRangeQuery { \
432+ bounds: BoundsRange { lower_bound: Included(Term(field=6, type=Json, path=hello, \
433+ type=Str, \" 2020-12-09T16:09:53+00:00\" )), upper_bound: Included(Term(field=6, \
434+ type=Json, path=hello, type=Str, \" 2020-12-09T16:09:53+00:00\" )) } })], filter: [], \
435+ minimum_should_match: None })"
436+ ) ;
437+ }
438+
407439 #[ test]
408440 fn test_range_query_not_fast_field ( ) {
409441 let range_query = RangeQuery {
0 commit comments