mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-27 08:41:00 +00:00
Add support for placeholder search for empty queries
This commit is contained in:
committed by
Clément Renault
parent
433d9bbc6e
commit
a00f5850ee
14
src/lib.rs
14
src/lib.rs
@ -14,6 +14,7 @@ use csv::StringRecord;
|
||||
use fxhash::{FxHasher32, FxHasher64};
|
||||
use heed::types::*;
|
||||
use heed::{PolyDatabase, Database};
|
||||
use roaring::RoaringBitmap;
|
||||
|
||||
pub use self::search::{Search, SearchResult};
|
||||
pub use self::criterion::{Criterion, default_criteria};
|
||||
@ -61,6 +62,10 @@ impl Index {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn documents_ids(&self, rtxn: &heed::RoTxn) -> anyhow::Result<Option<RoaringBitmap>> {
|
||||
Ok(self.main.get::<_, Str, RoaringBitmapCodec>(rtxn, DOCUMENTS_IDS_KEY)?)
|
||||
}
|
||||
|
||||
pub fn put_headers(&self, wtxn: &mut heed::RwTxn, headers: &StringRecord) -> heed::Result<()> {
|
||||
self.main.put::<_, Str, CsvStringRecordCodec>(wtxn, HEADERS_KEY, headers)
|
||||
}
|
||||
@ -114,10 +119,11 @@ impl Index {
|
||||
}
|
||||
|
||||
/// Returns the number of documents indexed in the database.
|
||||
pub fn number_of_documents<'t>(&self, rtxn: &'t heed::RoTxn) -> anyhow::Result<usize> {
|
||||
let docids = self.main.get::<_, Str, RoaringBitmapCodec>(rtxn, DOCUMENTS_IDS_KEY)?
|
||||
.with_context(|| format!("Could not find the list of documents ids"))?;
|
||||
Ok(docids.len() as usize)
|
||||
pub fn number_of_documents(&self, rtxn: &heed::RoTxn) -> anyhow::Result<usize> {
|
||||
match self.documents_ids(rtxn)? {
|
||||
Some(docids) => Ok(docids.len() as usize),
|
||||
None => Ok(0),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn search<'a>(&'a self, rtxn: &'a heed::RoTxn) -> Search<'a> {
|
||||
|
Reference in New Issue
Block a user