mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-09 22:48:54 +01:00
Remove the invalid get_phrases_docids universe parameter
This commit is contained in:
parent
cd7a20fa32
commit
93ba051094
@ -29,7 +29,7 @@ fn compute_docids(
|
|||||||
|
|
||||||
let candidates = match exact_term {
|
let candidates = match exact_term {
|
||||||
// TODO I move the intersection here
|
// TODO I move the intersection here
|
||||||
ExactTerm::Phrase(phrase) => ctx.get_phrase_docids(None, phrase)? & universe,
|
ExactTerm::Phrase(phrase) => ctx.get_phrase_docids(phrase)? & universe,
|
||||||
ExactTerm::Word(word) => {
|
ExactTerm::Word(word) => {
|
||||||
ctx.word_docids(Some(universe), Word::Original(word))?.unwrap_or_default()
|
ctx.word_docids(Some(universe), Word::Original(word))?.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ pub fn compute_docids(
|
|||||||
if right_derivs.len() > 1 {
|
if right_derivs.len() > 1 {
|
||||||
let universe = &universe;
|
let universe = &universe;
|
||||||
if let Some(left_phrase) = left_phrase {
|
if let Some(left_phrase) = left_phrase {
|
||||||
if universe.is_disjoint(ctx.get_phrase_docids(None, left_phrase)?) {
|
if universe.is_disjoint(ctx.get_phrase_docids(left_phrase)?) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if let Some(left_word_docids) = ctx.word_docids(Some(universe), left_word)? {
|
} else if let Some(left_word_docids) = ctx.word_docids(Some(universe), left_word)? {
|
||||||
@ -126,7 +126,7 @@ fn compute_prefix_edges(
|
|||||||
// TODO we can clearly give the universe to this method
|
// TODO we can clearly give the universe to this method
|
||||||
// Unfortunately, it is deserializing/computing stuff and
|
// Unfortunately, it is deserializing/computing stuff and
|
||||||
// keeping the result as a materialized bitmap.
|
// keeping the result as a materialized bitmap.
|
||||||
let phrase_docids = ctx.get_phrase_docids(None, phrase)?;
|
let phrase_docids = ctx.get_phrase_docids(phrase)?;
|
||||||
if !phrase_docids.is_empty() {
|
if !phrase_docids.is_empty() {
|
||||||
used_left_phrases.insert(phrase);
|
used_left_phrases.insert(phrase);
|
||||||
}
|
}
|
||||||
@ -184,7 +184,7 @@ fn compute_non_prefix_edges(
|
|||||||
let mut universe = universe.clone();
|
let mut universe = universe.clone();
|
||||||
|
|
||||||
for phrase in left_phrase.iter().chain(right_phrase.iter()).copied() {
|
for phrase in left_phrase.iter().chain(right_phrase.iter()).copied() {
|
||||||
universe &= ctx.get_phrase_docids(None, phrase)?;
|
universe &= ctx.get_phrase_docids(phrase)?;
|
||||||
if universe.is_empty() {
|
if universe.is_empty() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
@ -19,15 +19,11 @@ pub struct PhraseDocIdsCache {
|
|||||||
}
|
}
|
||||||
impl<'ctx> SearchContext<'ctx> {
|
impl<'ctx> SearchContext<'ctx> {
|
||||||
/// Get the document ids associated with the given phrase
|
/// Get the document ids associated with the given phrase
|
||||||
pub fn get_phrase_docids(
|
pub fn get_phrase_docids(&mut self, phrase: Interned<Phrase>) -> Result<&RoaringBitmap> {
|
||||||
&mut self,
|
|
||||||
universe: Option<&RoaringBitmap>,
|
|
||||||
phrase: Interned<Phrase>,
|
|
||||||
) -> Result<&RoaringBitmap> {
|
|
||||||
if self.phrase_docids.cache.contains_key(&phrase) {
|
if self.phrase_docids.cache.contains_key(&phrase) {
|
||||||
return Ok(&self.phrase_docids.cache[&phrase]);
|
return Ok(&self.phrase_docids.cache[&phrase]);
|
||||||
};
|
};
|
||||||
let docids = compute_phrase_docids(self, universe, phrase)?;
|
let docids = compute_phrase_docids(self, phrase)?;
|
||||||
// TODO can we improve that? Because there is an issue, we keep that in cache...
|
// TODO can we improve that? Because there is an issue, we keep that in cache...
|
||||||
let _ = self.phrase_docids.cache.insert(phrase, docids);
|
let _ = self.phrase_docids.cache.insert(phrase, docids);
|
||||||
let docids = &self.phrase_docids.cache[&phrase];
|
let docids = &self.phrase_docids.cache[&phrase];
|
||||||
@ -47,7 +43,7 @@ pub fn compute_query_term_subset_docids(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for phrase in term.all_phrases(ctx)? {
|
for phrase in term.all_phrases(ctx)? {
|
||||||
docids |= ctx.get_phrase_docids(None, phrase)?;
|
docids |= ctx.get_phrase_docids(phrase)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(prefix) = term.use_prefix_db(ctx) {
|
if let Some(prefix) = term.use_prefix_db(ctx) {
|
||||||
@ -80,7 +76,7 @@ pub fn compute_query_term_subset_docids_within_field_id(
|
|||||||
// guaranteed that all of its words are within a single fid.
|
// guaranteed that all of its words are within a single fid.
|
||||||
if let Some(word) = phrase.words(ctx).iter().flatten().next() {
|
if let Some(word) = phrase.words(ctx).iter().flatten().next() {
|
||||||
if let Some(word_fid_docids) = ctx.get_db_word_fid_docids(universe, *word, fid)? {
|
if let Some(word_fid_docids) = ctx.get_db_word_fid_docids(universe, *word, fid)? {
|
||||||
docids |= ctx.get_phrase_docids(None, phrase)? & word_fid_docids;
|
docids |= ctx.get_phrase_docids(phrase)? & word_fid_docids;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,7 +114,7 @@ pub fn compute_query_term_subset_docids_within_position(
|
|||||||
if let Some(word_position_docids) =
|
if let Some(word_position_docids) =
|
||||||
ctx.get_db_word_position_docids(universe, *word, position)?
|
ctx.get_db_word_position_docids(universe, *word, position)?
|
||||||
{
|
{
|
||||||
docids |= ctx.get_phrase_docids(None, phrase)? & word_position_docids;
|
docids |= ctx.get_phrase_docids(phrase)? & word_position_docids;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -190,7 +186,6 @@ pub fn compute_query_graph_docids(
|
|||||||
|
|
||||||
pub fn compute_phrase_docids(
|
pub fn compute_phrase_docids(
|
||||||
ctx: &mut SearchContext<'_>,
|
ctx: &mut SearchContext<'_>,
|
||||||
universe: Option<&RoaringBitmap>,
|
|
||||||
phrase: Interned<Phrase>,
|
phrase: Interned<Phrase>,
|
||||||
) -> Result<RoaringBitmap> {
|
) -> Result<RoaringBitmap> {
|
||||||
let Phrase { words } = ctx.phrase_interner.get(phrase).clone();
|
let Phrase { words } = ctx.phrase_interner.get(phrase).clone();
|
||||||
@ -200,7 +195,7 @@ pub fn compute_phrase_docids(
|
|||||||
}
|
}
|
||||||
let mut candidates = RoaringBitmap::new();
|
let mut candidates = RoaringBitmap::new();
|
||||||
for word in words.iter().flatten().copied() {
|
for word in words.iter().flatten().copied() {
|
||||||
if let Some(word_docids) = ctx.word_docids(universe, Word::Original(word))? {
|
if let Some(word_docids) = ctx.word_docids(None, Word::Original(word))? {
|
||||||
candidates |= word_docids;
|
candidates |= word_docids;
|
||||||
} else {
|
} else {
|
||||||
return Ok(RoaringBitmap::new());
|
return Ok(RoaringBitmap::new());
|
||||||
@ -224,7 +219,7 @@ pub fn compute_phrase_docids(
|
|||||||
.filter_map(|(index, word)| word.as_ref().map(|word| (index, word)))
|
.filter_map(|(index, word)| word.as_ref().map(|word| (index, word)))
|
||||||
{
|
{
|
||||||
if dist == 0 {
|
if dist == 0 {
|
||||||
match ctx.get_db_word_pair_proximity_docids(universe, s1, s2, 1)? {
|
match ctx.get_db_word_pair_proximity_docids(None, s1, s2, 1)? {
|
||||||
Some(m) => bitmaps.push(m),
|
Some(m) => bitmaps.push(m),
|
||||||
// If there are no documents for this pair, there will be no
|
// If there are no documents for this pair, there will be no
|
||||||
// results for the phrase query.
|
// results for the phrase query.
|
||||||
@ -234,7 +229,7 @@ pub fn compute_phrase_docids(
|
|||||||
let mut bitmap = RoaringBitmap::new();
|
let mut bitmap = RoaringBitmap::new();
|
||||||
for dist in 0..=dist {
|
for dist in 0..=dist {
|
||||||
if let Some(m) =
|
if let Some(m) =
|
||||||
ctx.get_db_word_pair_proximity_docids(universe, s1, s2, dist as u8 + 1)?
|
ctx.get_db_word_pair_proximity_docids(None, s1, s2, dist as u8 + 1)?
|
||||||
{
|
{
|
||||||
bitmap |= m;
|
bitmap |= m;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user