Skip to content

Commit 10f61dc

Browse files
author
Adam Reichold
committed
Add method to take clauses out of boolean query
This helps with rewriting, for example to replace the default score combiner used by boolean queries, insofer it avoids the need to `box_clone` the sub queries.
1 parent e488f9e commit 10f61dc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/query/boolean_query/boolean_query.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::mem;
2+
13
use super::boolean_weight::BooleanWeight;
24
use crate::query::{EnableScoring, Occur, Query, SumCombiner, TermQuery, Weight};
35
use crate::schema::{IndexRecordOption, Term};
@@ -257,6 +259,11 @@ impl BooleanQuery {
257259
pub fn clauses(&self) -> &[(Occur, Box<dyn Query>)] {
258260
&self.subqueries[..]
259261
}
262+
263+
/// Take the clauses making up this query for reuse.
264+
pub fn take_clauses(&mut self) -> Vec<(Occur, Box<dyn Query>)> {
265+
mem::take(&mut self.subqueries)
266+
}
260267
}
261268

262269
#[cfg(test)]

0 commit comments

Comments
 (0)