Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make BlockSegmentPostings::open and TermInfoStore public #2520

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/postings/block_segment_postings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl BlockSegmentPostings {
/// `requested_option` is the amount of data requested by the user.
/// If for instance, we do not request for term frequencies, this function will not decompress
/// term frequency blocks.
pub(crate) fn open(
pub fn open(
doc_freq: u32,
data: FileSlice,
mut record_option: IndexRecordOption,
Expand Down
10 changes: 10 additions & 0 deletions src/query/boost_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ impl BoostQuery {
pub fn new(query: Box<dyn Query>, boost: Score) -> BoostQuery {
BoostQuery { query, boost }
}

/// The wrapped query.
pub fn query(&self) -> Box<dyn Query> {
b41sh marked this conversation as resolved.
Show resolved Hide resolved
self.query.box_clone()
}

/// The boost score.
pub fn boost(&self) -> Score {
b41sh marked this conversation as resolved.
Show resolved Hide resolved
self.boost
}
}

impl Clone for BoostQuery {
Expand Down
10 changes: 10 additions & 0 deletions src/query/const_score_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ impl ConstScoreQuery {
pub fn new(query: Box<dyn Query>, score: Score) -> ConstScoreQuery {
ConstScoreQuery { query, score }
}

/// The wrapped query.
pub fn query(&self) -> Box<dyn Query> {
b41sh marked this conversation as resolved.
Show resolved Hide resolved
self.query.box_clone()
}

/// The constant score.
pub fn score(&self) -> Score {
b41sh marked this conversation as resolved.
Show resolved Hide resolved
b41sh marked this conversation as resolved.
Show resolved Hide resolved
self.score
}
}

impl Clone for ConstScoreQuery {
Expand Down
9 changes: 9 additions & 0 deletions src/query/fuzzy_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,21 @@ impl FuzzyTermQuery {
))
}
}

/// The `Term` this query is built out of.
pub fn term(&self) -> &Term {
&self.term
}
}

impl Query for FuzzyTermQuery {
fn weight(&self, _enable_scoring: EnableScoring<'_>) -> crate::Result<Box<dyn Weight>> {
Ok(Box::new(self.specialized_weight()?))
}

fn query_terms<'a>(&'a self, visitor: &mut dyn FnMut(&'a Term, bool)) {
visitor(&self.term, false);
}
}

#[cfg(test)]
Expand Down
10 changes: 10 additions & 0 deletions src/query/phrase_prefix_query/phrase_prefix_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ impl PhrasePrefixQuery {
.collect::<Vec<Term>>()
}

/// `Term`s in the phrase with the associated offsets.
pub fn phrase_terms_with_offsets(&self) -> Vec<(usize, Term)> {
b41sh marked this conversation as resolved.
Show resolved Hide resolved
self.phrase_terms.clone()
}

/// The prefix `Term` in the phrase with the associated offset.
pub fn prefix_term_with_offset(&self) -> (usize, Term) {
self.prefix.clone()
}

/// Returns the [`PhrasePrefixWeight`] for the given phrase query given a specific `searcher`.
///
/// This function is the same as [`Query::weight()`] except it returns
Expand Down
5 changes: 5 additions & 0 deletions src/query/phrase_query/phrase_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ impl PhraseQuery {
.collect::<Vec<Term>>()
}

/// `Term`s in the phrase with the associated offsets.
pub fn phrase_terms_with_offsets(&self) -> Vec<(usize, Term)> {
b41sh marked this conversation as resolved.
Show resolved Hide resolved
self.phrase_terms.clone()
}

/// Returns the [`PhraseWeight`] for the given phrase query given a specific `searcher`.
///
/// This function is the same as [`Query::weight()`] except it returns
Expand Down
1 change: 1 addition & 0 deletions src/termdict/fst_termdict/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ mod termdict;

pub use self::merger::TermMerger;
pub use self::streamer::{TermStreamer, TermStreamerBuilder};
pub use self::term_info_store::TermInfoStore;
pub use self::termdict::{TermDictionary, TermDictionaryBuilder};
2 changes: 2 additions & 0 deletions src/termdict/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
mod fst_termdict;
#[cfg(not(feature = "quickwit"))]
use fst_termdict as termdict;
#[cfg(not(feature = "quickwit"))]
pub use fst_termdict::TermInfoStore;

#[cfg(feature = "quickwit")]
mod sstable_termdict;
Expand Down
Loading