mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-27 04:25:06 +08:00
Fix phrase search bug when the phrase has only one word
This commit is contained in:
parent
d48cdc67a0
commit
0d6e8b5c31
@ -121,14 +121,27 @@ pub fn compute_phrase_docids(
|
|||||||
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();
|
||||||
|
|
||||||
|
if words.is_empty() {
|
||||||
|
return Ok(RoaringBitmap::new());
|
||||||
|
}
|
||||||
|
if words.len() == 1 {
|
||||||
|
if let Some(word) = &words[0] {
|
||||||
|
if let Some(word_docids) = ctx.get_db_word_docids(*word)? {
|
||||||
|
return RoaringBitmapCodec::bytes_decode(word_docids)
|
||||||
|
.ok_or(heed::Error::Decoding.into());
|
||||||
|
} else {
|
||||||
|
return Ok(RoaringBitmap::new());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Ok(RoaringBitmap::new());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut candidates = RoaringBitmap::new();
|
let mut candidates = RoaringBitmap::new();
|
||||||
let mut first_iter = true;
|
let mut first_iter = true;
|
||||||
let winsize = words.len().min(3);
|
let winsize = words.len().min(3);
|
||||||
|
|
||||||
if words.is_empty() {
|
|
||||||
return Ok(candidates);
|
|
||||||
}
|
|
||||||
|
|
||||||
for win in words.windows(winsize) {
|
for win in words.windows(winsize) {
|
||||||
// Get all the documents with the matching distance for each word pairs.
|
// Get all the documents with the matching distance for each word pairs.
|
||||||
let mut bitmaps = Vec::with_capacity(winsize.pow(2));
|
let mut bitmaps = Vec::with_capacity(winsize.pow(2));
|
||||||
|
Loading…
Reference in New Issue
Block a user