From 3415812b06291f5ee7504513f76dbcf411823c26 Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Wed, 24 Feb 2021 14:48:12 +0100 Subject: [PATCH] Imrpove the intersection speed in the words criterion --- milli/src/search/criteria/words.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/milli/src/search/criteria/words.rs b/milli/src/search/criteria/words.rs index 93298b64e..cf1668055 100644 --- a/milli/src/search/criteria/words.rs +++ b/milli/src/search/criteria/words.rs @@ -129,10 +129,15 @@ fn resolve_candidates<'t>( match query_tree { And(ops) => { + let mut ops = ops.iter().map(|op| { + resolve_operation(ctx, op, cache) + }).collect::>>()?; + + ops.sort_unstable_by_key(|cds| cds.len()); + let mut candidates = RoaringBitmap::new(); let mut first_loop = true; - for op in ops { - let docids = resolve_operation(ctx, op, cache)?; + for docids in ops { if first_loop { candidates = docids; first_loop = false;