@@ -5076,4 +5076,89 @@ mod tests {
5076
5076
assert_eq ! ( search_response. failed_splits. len( ) , 1 ) ;
5077
5077
Ok ( ( ) )
5078
5078
}
5079
+
5080
+ #[ tokio:: test]
5081
+ async fn test_search_partial_hits_phase_filters_by_time_range ( ) -> anyhow:: Result < ( ) > {
5082
+ let search_request = quickwit_proto:: search:: SearchRequest {
5083
+ start_timestamp : Some ( 122_000 ) ,
5084
+ end_timestamp : Some ( 129_000 ) ,
5085
+ index_id_patterns : vec ! [ "test-index" . to_string( ) ] ,
5086
+ query_ast : qast_json_helper ( "test" , & [ "body" ] ) ,
5087
+ max_hits : 10 ,
5088
+ ..Default :: default ( )
5089
+ } ;
5090
+
5091
+ let index_metadata = IndexMetadata :: for_test ( "test-index" , "ram:///test-index" ) ;
5092
+ let index_uid = index_metadata. index_uid . clone ( ) ;
5093
+
5094
+ let mut mock_metastore = MockMetastoreService :: new ( ) ;
5095
+ mock_metastore
5096
+ . expect_list_indexes_metadata ( )
5097
+ . returning ( move |_q| {
5098
+ Ok ( ListIndexesMetadataResponse :: for_test ( vec ! [
5099
+ index_metadata. clone( ) ,
5100
+ ] ) )
5101
+ } ) ;
5102
+ mock_metastore. expect_list_splits ( ) . returning ( move |_req| {
5103
+ let splits = vec ! [
5104
+ MockSplitBuilder :: new_with_time_range( "split_before" , Some ( 100_000 ..=110_000 ) )
5105
+ . with_index_uid( & index_uid)
5106
+ . build( ) ,
5107
+ MockSplitBuilder :: new_with_time_range(
5108
+ "split_overlap_start" ,
5109
+ Some ( 120_000 ..=123_000 ) ,
5110
+ )
5111
+ . with_index_uid( & index_uid)
5112
+ . build( ) ,
5113
+ MockSplitBuilder :: new_with_time_range( "split_overlap_end" , Some ( 128_000 ..=140_000 ) )
5114
+ . with_index_uid( & index_uid)
5115
+ . build( ) ,
5116
+ MockSplitBuilder :: new_with_time_range(
5117
+ "split_covering_whole" ,
5118
+ Some ( 100_000 ..=200_000 ) ,
5119
+ )
5120
+ . with_index_uid( & index_uid)
5121
+ . build( ) ,
5122
+ MockSplitBuilder :: new_with_time_range( "split_inside" , Some ( 124_000 ..=126_000 ) )
5123
+ . with_index_uid( & index_uid)
5124
+ . build( ) ,
5125
+ ] ;
5126
+ let resp = ListSplitsResponse :: try_from_splits ( splits) . unwrap ( ) ;
5127
+ Ok ( ServiceStream :: from ( vec ! [ Ok ( resp) ] ) )
5128
+ } ) ;
5129
+
5130
+ let mut mock_search = MockSearchService :: new ( ) ;
5131
+ mock_search. expect_leaf_search ( ) . times ( 1 ) . returning ( |_req| {
5132
+ Ok ( quickwit_proto:: search:: LeafSearchResponse {
5133
+ num_hits : 1 ,
5134
+ partial_hits : vec ! [ mock_partial_hit( "split_inside" , 1 , 1 ) ] ,
5135
+ failed_splits : Vec :: new ( ) ,
5136
+ num_attempted_splits : 1 ,
5137
+ ..Default :: default ( )
5138
+ } )
5139
+ } ) ;
5140
+ mock_search. expect_fetch_docs ( ) . returning ( |fetch_req| {
5141
+ Ok ( quickwit_proto:: search:: FetchDocsResponse {
5142
+ hits : get_doc_for_fetch_req ( fetch_req) ,
5143
+ } )
5144
+ } ) ;
5145
+
5146
+ let searcher_pool = searcher_pool_for_test ( [ ( "127.0.0.1:1001" , mock_search) ] ) ;
5147
+ let search_job_placer = SearchJobPlacer :: new ( searcher_pool) ;
5148
+ let cluster_client = ClusterClient :: new ( search_job_placer) ;
5149
+
5150
+ let ctx = SearcherContext :: for_test ( ) ;
5151
+ let resp = root_search (
5152
+ & ctx,
5153
+ search_request,
5154
+ MetastoreServiceClient :: from_mock ( mock_metastore) ,
5155
+ & cluster_client,
5156
+ )
5157
+ . await ?;
5158
+
5159
+ assert_eq ! ( resp. num_hits, 1 ) ;
5160
+ assert_eq ! ( resp. hits. len( ) , 1 ) ;
5161
+
5162
+ Ok ( ( ) )
5163
+ }
5079
5164
}
0 commit comments