diff options
author | Paul Masurel <paul.masurel@gmail.com> | 2016-10-29 14:41:50 +0900 |
---|---|---|
committer | Paul Masurel <paul.masurel@gmail.com> | 2016-10-29 14:41:50 +0900 |
commit | 67b1071412a13e69cd49eb40ec6af7998b8c0f26 (patch) | |
tree | 651fa4efb958ab4ba95ca7e44f3e42aca039fddd /src/query/scorer.rs | |
parent | 0ca78328759b1c85ca791fe849f7f3c139295012 (diff) |
issue/50 Moved segment local collection to the DocSet object.
Diffstat (limited to 'src/query/scorer.rs')
-rw-r--r-- | src/query/scorer.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/query/scorer.rs b/src/query/scorer.rs index 7e9f174..21d57ee 100644 --- a/src/query/scorer.rs +++ b/src/query/scorer.rs @@ -1,5 +1,6 @@ use DocSet; - +use ScoredDoc; +use collector::Collector; /// Scored `DocSet` pub trait Scorer: DocSet { @@ -8,6 +9,13 @@ pub trait Scorer: DocSet { /// /// This method will perform a bit of computation and is not cached. fn score(&self,) -> f32; + + fn collect(&mut self, collector: &mut Collector) { + while self.advance() { + let scored_doc = ScoredDoc(self.score(), self.doc()); + collector.collect(scored_doc); + } + } } |