@@ -301,7 +301,7 @@ impl FullTextQuery {
301301
302302#[ cfg( test) ]
303303mod tests {
304- use tantivy:: schema:: { Schema , TEXT } ;
304+ use tantivy:: schema:: { DateOptions , DateTimePrecision , Schema , TEXT } ;
305305
306306 use crate :: BooleanOperand ;
307307 use crate :: query_ast:: tantivy_query_ast:: TantivyQueryAst ;
@@ -379,6 +379,59 @@ mod tests {
379379 ) ;
380380 }
381381
382+ #[ test]
383+ fn test_full_text_datetime ( ) {
384+ let full_text_query = FullTextQuery {
385+ field : "ts" . to_string ( ) ,
386+ text : "2025-12-13T16:13:12.666777Z" . to_string ( ) ,
387+ params : super :: FullTextParams {
388+ tokenizer : Some ( "raw" . to_string ( ) ) ,
389+ mode : FullTextMode :: Phrase { slop : 1 } ,
390+ zero_terms_query : crate :: MatchAllOrNone :: MatchAll ,
391+ } ,
392+ lenient : false ,
393+ } ;
394+ {
395+ // indexed, we truncate to the second
396+ let mut schema_builder = Schema :: builder ( ) ;
397+ schema_builder. add_date_field (
398+ "ts" ,
399+ DateOptions :: default ( )
400+ . set_precision ( DateTimePrecision :: Milliseconds )
401+ . set_fast ( )
402+ . set_indexed ( ) ,
403+ ) ;
404+ let schema = schema_builder. build ( ) ;
405+ let ast: TantivyQueryAst = full_text_query
406+ . build_tantivy_ast_call ( & BuildTantivyAstContext :: for_test ( & schema) )
407+ . unwrap ( ) ;
408+ let leaf = ast. as_leaf ( ) . unwrap ( ) ;
409+ assert_eq ! (
410+ & format!( "{leaf:?}" ) ,
411+ r#"TermQuery(Term(field=0, type=Date, 2025-12-13T16:13:12Z))"#
412+ ) ;
413+ }
414+ {
415+ // not indexed, we truncate to fastfield precision
416+ let mut schema_builder = Schema :: builder ( ) ;
417+ schema_builder. add_date_field (
418+ "ts" ,
419+ DateOptions :: default ( )
420+ . set_precision ( DateTimePrecision :: Milliseconds )
421+ . set_fast ( ) ,
422+ ) ;
423+ let schema = schema_builder. build ( ) ;
424+ let ast: TantivyQueryAst = full_text_query
425+ . build_tantivy_ast_call ( & BuildTantivyAstContext :: for_test ( & schema) )
426+ . unwrap ( ) ;
427+ let leaf = ast. as_leaf ( ) . unwrap ( ) ;
428+ assert_eq ! (
429+ & format!( "{leaf:?}" ) ,
430+ r#"TermQuery(Term(field=0, type=Date, 2025-12-13T16:13:12.666Z))"#
431+ ) ;
432+ }
433+ }
434+
382435 #[ test]
383436 fn test_full_text_bool_mode ( ) {
384437 let full_text_query = FullTextQuery {
0 commit comments