mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Test and implement settings opt-out
This commit is contained in:
parent
5560452ef9
commit
d66dc363ed
36 changed files with 1018 additions and 94 deletions
|
@ -70,6 +70,8 @@ pub mod main_key {
|
|||
pub const EMBEDDING_CONFIGS: &str = "embedding_configs";
|
||||
pub const SEARCH_CUTOFF: &str = "search_cutoff";
|
||||
pub const LOCALIZED_ATTRIBUTES_RULES: &str = "localized_attributes_rules";
|
||||
pub const FACET_SEARCH: &str = "facet_search";
|
||||
pub const PREFIX_SEARCH: &str = "prefix_search";
|
||||
}
|
||||
|
||||
pub mod db_name {
|
||||
|
@ -1233,6 +1235,10 @@ impl Index {
|
|||
)
|
||||
}
|
||||
|
||||
pub(crate) fn delete_words_prefixes_fst(&self, wtxn: &mut RwTxn<'_>) -> heed::Result<bool> {
|
||||
self.main.remap_key_type::<Str>().delete(wtxn, main_key::WORDS_PREFIXES_FST_KEY)
|
||||
}
|
||||
|
||||
/// Returns the FST which is the words prefixes dictionary of the engine.
|
||||
pub fn words_prefixes_fst<'t>(&self, rtxn: &'t RoTxn<'t>) -> Result<fst::Set<Cow<'t, [u8]>>> {
|
||||
match self.main.remap_types::<Str, Bytes>().get(rtxn, main_key::WORDS_PREFIXES_FST_KEY)? {
|
||||
|
@ -1562,6 +1568,41 @@ impl Index {
|
|||
self.main.remap_key_type::<Str>().delete(txn, main_key::PROXIMITY_PRECISION)
|
||||
}
|
||||
|
||||
pub fn prefix_search(&self, txn: &RoTxn<'_>) -> heed::Result<Option<PrefixSearch>> {
|
||||
self.main.remap_types::<Str, SerdeBincode<PrefixSearch>>().get(txn, main_key::PREFIX_SEARCH)
|
||||
}
|
||||
|
||||
pub(crate) fn put_prefix_search(
|
||||
&self,
|
||||
txn: &mut RwTxn<'_>,
|
||||
val: PrefixSearch,
|
||||
) -> heed::Result<()> {
|
||||
self.main.remap_types::<Str, SerdeBincode<PrefixSearch>>().put(
|
||||
txn,
|
||||
main_key::PREFIX_SEARCH,
|
||||
&val,
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn delete_prefix_search(&self, txn: &mut RwTxn<'_>) -> heed::Result<bool> {
|
||||
self.main.remap_key_type::<Str>().delete(txn, main_key::PREFIX_SEARCH)
|
||||
}
|
||||
|
||||
pub fn facet_search(&self, txn: &RoTxn<'_>) -> heed::Result<bool> {
|
||||
self.main
|
||||
.remap_types::<Str, SerdeBincode<bool>>()
|
||||
.get(txn, main_key::FACET_SEARCH)
|
||||
.map(|v| v.unwrap_or(true))
|
||||
}
|
||||
|
||||
pub(crate) fn put_facet_search(&self, txn: &mut RwTxn<'_>, val: bool) -> heed::Result<()> {
|
||||
self.main.remap_types::<Str, SerdeBincode<bool>>().put(txn, main_key::FACET_SEARCH, &val)
|
||||
}
|
||||
|
||||
pub(crate) fn delete_facet_search(&self, txn: &mut RwTxn<'_>) -> heed::Result<bool> {
|
||||
self.main.remap_key_type::<Str>().delete(txn, main_key::FACET_SEARCH)
|
||||
}
|
||||
|
||||
pub fn localized_attributes_rules(
|
||||
&self,
|
||||
rtxn: &RoTxn<'_>,
|
||||
|
@ -1647,10 +1688,14 @@ impl Index {
|
|||
Ok(res)
|
||||
}
|
||||
|
||||
pub fn prefix_settings(&self, _rtxn: &RoTxn<'_>) -> Result<PrefixSettings> {
|
||||
pub fn prefix_settings(&self, rtxn: &RoTxn<'_>) -> Result<PrefixSettings> {
|
||||
let compute_prefixes = self.prefix_search(rtxn)?.unwrap_or_default();
|
||||
Ok(PrefixSettings {
|
||||
compute_prefixes: true,
|
||||
compute_prefixes,
|
||||
max_prefix_length: 4,
|
||||
#[cfg(not(test))]
|
||||
prefix_count_threshold: 100,
|
||||
#[cfg(test)]
|
||||
prefix_count_threshold: 100,
|
||||
})
|
||||
}
|
||||
|
@ -1665,9 +1710,17 @@ pub struct IndexEmbeddingConfig {
|
|||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct PrefixSettings {
|
||||
pub prefix_count_threshold: u64,
|
||||
pub prefix_count_threshold: usize,
|
||||
pub max_prefix_length: usize,
|
||||
pub compute_prefixes: bool,
|
||||
pub compute_prefixes: PrefixSearch,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum PrefixSearch {
|
||||
#[default]
|
||||
IndexingTime,
|
||||
Disabled,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue