From 7132c3be899adad444c5583f543d3ad3efa2978f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Sat, 29 Dec 2018 20:16:59 +0100 Subject: [PATCH] feat: Allow filtering on QueryBuilder --- src/rank/query_builder.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/rank/query_builder.rs b/src/rank/query_builder.rs index 103a9a30d..39419024c 100644 --- a/src/rank/query_builder.rs +++ b/src/rank/query_builder.rs @@ -124,7 +124,14 @@ impl<'a, D, FI> QueryBuilder<'a, D, FI> where D: Deref, FI: Fn(DocumentId, &DatabaseView) -> bool, { - pub fn query(&self, query: &str, range: Range) -> Vec { + pub fn query(self, query: &str, range: Range) -> Vec { + // We give the filtering work to the query distinct builder, + // specifying a distinct rule that has no effect. + if self.filter.is_some() { + let builder = self.with_distinct(|_, _| None as Option<()>, 1); + return builder.query(query, range); + } + let mut documents = self.query_all(query); let mut groups = vec![documents.as_mut_slice()]; let view = &self.view;