mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 12:27:13 +02:00
push a first implementation of the stop_words
This commit is contained in:
parent
2206a44baf
commit
40ef9a3c6a
6 changed files with 66 additions and 15 deletions
|
@ -1,7 +1,7 @@
|
|||
mod search;
|
||||
mod updates;
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::collections::{BTreeSet, HashSet};
|
||||
use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
@ -51,11 +51,24 @@ impl Index {
|
|||
.map(|c| c.to_string())
|
||||
.collect();
|
||||
|
||||
let stop_words = self
|
||||
.stop_words(&txn)?
|
||||
.map(|stop_words| -> anyhow::Result<BTreeSet<_>> {
|
||||
Ok(stop_words
|
||||
.stream()
|
||||
.into_strs()?
|
||||
.into_iter()
|
||||
.collect())
|
||||
})
|
||||
.transpose()?
|
||||
.unwrap_or_else(BTreeSet::new);
|
||||
|
||||
Ok(Settings {
|
||||
displayed_attributes: Some(Some(displayed_attributes)),
|
||||
searchable_attributes: Some(Some(searchable_attributes)),
|
||||
attributes_for_faceting: Some(Some(faceted_attributes)),
|
||||
ranking_rules: Some(Some(criteria)),
|
||||
stop_words: Some(Some(stop_words)),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::collections::HashMap;
|
||||
use std::collections::{BTreeSet, HashMap};
|
||||
use std::io;
|
||||
use std::num::NonZeroUsize;
|
||||
|
||||
|
@ -44,8 +44,12 @@ pub struct Settings {
|
|||
)]
|
||||
pub ranking_rules: Option<Option<Vec<String>>>,
|
||||
|
||||
// TODO we are missing the stopWords, synonyms and distinctAttribute for the GET settings
|
||||
// request
|
||||
#[serde(
|
||||
default,
|
||||
deserialize_with = "deserialize_some",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub stop_words: Option<Option<BTreeSet<String>>>,
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
|
@ -55,6 +59,7 @@ impl Settings {
|
|||
searchable_attributes: Some(None),
|
||||
attributes_for_faceting: Some(None),
|
||||
ranking_rules: Some(None),
|
||||
stop_words: Some(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,6 +175,14 @@ impl Index {
|
|||
}
|
||||
}
|
||||
|
||||
// We transpose the settings JSON struct into a real setting update.
|
||||
if let Some(ref stop_words) = settings.stop_words {
|
||||
match stop_words {
|
||||
Some(stop_words) => builder.set_stop_words(stop_words.clone()),
|
||||
_ => builder.reset_stop_words(),
|
||||
}
|
||||
}
|
||||
|
||||
let result = builder
|
||||
.execute(|indexing_step, update_id| info!("update {}: {:?}", update_id, indexing_step));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue