@@ -290,42 +290,10 @@ fn push_search_ctes<'a>(
290290 ) ;
291291 }
292292
293- if plan. required_terms . len ( ) == 1 {
293+ if ! plan. required_terms . is_empty ( ) {
294294 for predicate in & plan. required_terms {
295295 push_content_condition ( qb, predicate, case_mode, false ) ;
296296 }
297- } else if !plan. required_terms . is_empty ( ) {
298- qb. push ( " AND (" ) ;
299- for ( idx, predicate) in plan. required_terms . iter ( ) . enumerate ( ) {
300- if idx > 0 {
301- qb. push ( " OR " ) ;
302- }
303- qb. push ( "(" ) ;
304- push_content_predicate ( qb, predicate, case_mode, "c.text_content" ) ;
305- qb. push ( ")" ) ;
306- }
307- qb. push ( ")" ) ;
308-
309- qb. push ( " AND " ) ;
310- if seed_repo_first {
311- qb. push ( "f_seed.content_hash" ) ;
312- } else {
313- qb. push ( "cbc.content_hash" ) ;
314- }
315- qb. push ( " IN (" ) ;
316- for ( idx, predicate) in plan. required_terms . iter ( ) . enumerate ( ) {
317- if idx > 0 {
318- qb. push ( " INTERSECT " ) ;
319- }
320- qb. push (
321- "SELECT DISTINCT cbc_req.content_hash \
322- FROM content_blob_chunks cbc_req \
323- JOIN chunks c_req ON c_req.chunk_hash = cbc_req.chunk_hash \
324- WHERE ",
325- ) ;
326- push_content_predicate ( qb, predicate, case_mode, "c_req.text_content" ) ;
327- }
328- qb. push ( ")" ) ;
329297 }
330298
331299 for predicate in & plan. excluded_terms {
@@ -3628,11 +3596,11 @@ mod tests {
36283596 }
36293597
36303598 #[ test]
3631- fn multi_term_search_builds_intersect_filter ( ) {
3599+ fn multi_term_search_uses_chunk_local_and_filter ( ) {
36323600 let request = TextSearchRequest :: from_query_str ( "polly LinkAllPasses" ) . unwrap ( ) ;
36333601 let sql = build_phase1_sql ( & request) ;
3634- assert ! ( sql. contains( "INTERSECT" ) ) ;
3635- assert ! ( sql. contains( "cbc.content_hash IN (" ) ) ;
3602+ assert ! ( ! sql. contains( "INTERSECT" ) ) ;
3603+ assert ! ( ! sql. contains( "cbc.content_hash IN (" ) ) ;
36363604 }
36373605
36383606 #[ test]
0 commit comments