mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Merge #202
202: Add field id word count docids database r=Kerollmops a=LegendreM This PR introduces a new database, `field_id_word_count_docids`, that maps the number of words in an attribute with a list of document ids. This relation is limited to attributes that contain less than 11 words. This database is used by the exactness criterion to know if a document has an attribute that contains exactly the query without any additional word. Fix #165 Fix #196 Related to [specifications:#36](https://github.com/meilisearch/specifications/pull/36) Co-authored-by: many <maxime@meilisearch.com> Co-authored-by: Many <legendre.maxime.isn@gmail.com>
This commit is contained in:
commit
270da98c46
12 changed files with 193 additions and 22 deletions
22
milli/src/heed_codec/field_id_word_count_codec.rs
Normal file
22
milli/src/heed_codec/field_id_word_count_codec.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
use std::{borrow::Cow, convert::TryInto};
|
||||
|
||||
use crate::FieldId;
|
||||
|
||||
pub struct FieldIdWordCountCodec;
|
||||
|
||||
impl<'a> heed::BytesDecode<'a> for FieldIdWordCountCodec {
|
||||
type DItem = (FieldId, u8);
|
||||
|
||||
fn bytes_decode(bytes: &'a [u8]) -> Option<Self::DItem> {
|
||||
let [field_id, word_count]: [u8; 2] = bytes.try_into().ok()?;
|
||||
Some((field_id, word_count))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> heed::BytesEncode<'a> for FieldIdWordCountCodec {
|
||||
type EItem = (FieldId, u8);
|
||||
|
||||
fn bytes_encode((field_id, word_count): &Self::EItem) -> Option<Cow<[u8]>> {
|
||||
Some(Cow::Owned(vec![*field_id, *word_count]))
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ mod roaring_bitmap;
|
|||
mod roaring_bitmap_length;
|
||||
mod str_level_position_codec;
|
||||
mod str_str_u8_codec;
|
||||
mod field_id_word_count_codec;
|
||||
pub mod facet;
|
||||
|
||||
pub use self::beu32_str_codec::BEU32StrCodec;
|
||||
|
@ -12,3 +13,4 @@ pub use self::roaring_bitmap::{BoRoaringBitmapCodec, CboRoaringBitmapCodec, Roar
|
|||
pub use self::roaring_bitmap_length::{BoRoaringBitmapLenCodec, CboRoaringBitmapLenCodec, RoaringBitmapLenCodec};
|
||||
pub use self::str_level_position_codec::StrLevelPositionCodec;
|
||||
pub use self::str_str_u8_codec::StrStrU8Codec;
|
||||
pub use self::field_id_word_count_codec::FieldIdWordCountCodec;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue