mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-06-05 01:50:42 +00:00
small changes
This commit is contained in:
@@ -64,10 +64,9 @@ fn main() -> tantivy::Result<()> {
|
||||
|
||||
for doc_address in doc_addresses {
|
||||
let retrieved_doc = searcher.doc(&doc_address)?;
|
||||
generate_snippet(&retrieved_doc, query
|
||||
// generate_snippet(&retrieved_doc, query
|
||||
}
|
||||
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ impl<A> Weight for AutomatonWeight<A>
|
||||
where
|
||||
A: Automaton,
|
||||
{
|
||||
|
||||
fn matching_terms(&self,
|
||||
reader: &SegmentReader,
|
||||
matching_terms: &mut MatchingTerms) -> Result<()> {
|
||||
|
||||
@@ -13,6 +13,7 @@ use query::Weight;
|
||||
use std::borrow::Borrow;
|
||||
use std::collections::HashMap;
|
||||
use Result;
|
||||
use query::MatchingTerms;
|
||||
|
||||
fn scorer_union<TScoreCombiner>(scorers: Vec<Box<Scorer>>) -> Box<Scorer>
|
||||
where
|
||||
@@ -107,6 +108,14 @@ impl BooleanWeight {
|
||||
}
|
||||
|
||||
impl Weight for BooleanWeight {
|
||||
|
||||
fn matching_terms(&self, reader: &SegmentReader, matching_terms: &mut MatchingTerms) -> Result<()> {
|
||||
for (_, weight) in &self.weights {
|
||||
weight.matching_terms(reader, matching_terms)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn scorer(&self, reader: &SegmentReader) -> Result<Box<Scorer>> {
|
||||
if self.weights.is_empty() {
|
||||
Ok(Box::new(EmptyScorer))
|
||||
|
||||
@@ -7,6 +7,7 @@ use query::Weight;
|
||||
use schema::IndexRecordOption;
|
||||
use schema::Term;
|
||||
use Result;
|
||||
use query::MatchingTerms;
|
||||
|
||||
pub struct PhraseWeight {
|
||||
phrase_terms: Vec<(usize, Term)>,
|
||||
@@ -30,6 +31,11 @@ impl PhraseWeight {
|
||||
}
|
||||
|
||||
impl Weight for PhraseWeight {
|
||||
|
||||
fn matching_terms(&self, reader: &SegmentReader, matching_terms: &mut MatchingTerms) -> Result<()> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn scorer(&self, reader: &SegmentReader) -> Result<Box<Scorer>> {
|
||||
let similarity_weight = self.similarity_weight.clone();
|
||||
let field = self.phrase_terms[0].1.field();
|
||||
|
||||
@@ -11,6 +11,7 @@ use std::collections::Bound;
|
||||
use std::ops::Range;
|
||||
use termdict::{TermDictionary, TermStreamer};
|
||||
use Result;
|
||||
use query::MatchingTerms;
|
||||
|
||||
fn map_bound<TFrom, TTo, Transform: Fn(&TFrom) -> TTo>(
|
||||
bound: &Bound<TFrom>,
|
||||
@@ -274,6 +275,11 @@ impl RangeWeight {
|
||||
}
|
||||
|
||||
impl Weight for RangeWeight {
|
||||
|
||||
fn matching_terms(&self, reader: &SegmentReader, matching_terms: &mut MatchingTerms) -> Result<()> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn scorer(&self, reader: &SegmentReader) -> Result<Box<Scorer>> {
|
||||
let max_doc = reader.max_doc();
|
||||
let mut doc_bitset = BitSet::with_max_value(max_doc);
|
||||
|
||||
@@ -200,6 +200,7 @@ fn matching_terms(query: &Query, searcher: &Searcher, doc_addresses: &[DocAddres
|
||||
let segment_reader = searcher.segment_reader(segment_ord);
|
||||
weight.matching_terms(segment_reader, &mut matching_terms)?;
|
||||
}
|
||||
let terms = HashSet<(DocId, Vec<Term>)>;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -209,7 +210,7 @@ pub fn generate_snippet<'a>(
|
||||
query: &Query,
|
||||
terms: Vec<Term>,
|
||||
max_num_chars: usize) -> Snippet {
|
||||
unimplemented!();
|
||||
search_fragments(boxed_tokenizer, &text, terms, 3);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user