mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-27 04:25:06 +08:00
Introduce the searchable attributes setting to the settings route
This commit is contained in:
parent
63f65bac3e
commit
01c4f5abcd
@ -184,6 +184,13 @@ struct Settings {
|
|||||||
skip_serializing_if = "Option::is_none",
|
skip_serializing_if = "Option::is_none",
|
||||||
)]
|
)]
|
||||||
displayed_attributes: Option<Option<Vec<String>>>,
|
displayed_attributes: Option<Option<Vec<String>>>,
|
||||||
|
|
||||||
|
#[serde(
|
||||||
|
default,
|
||||||
|
deserialize_with = "deserialize_some",
|
||||||
|
skip_serializing_if = "Option::is_none",
|
||||||
|
)]
|
||||||
|
searchable_attributes: Option<Option<Vec<String>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Any value that is present is considered Some value, including null.
|
// Any value that is present is considered Some value, including null.
|
||||||
@ -300,6 +307,14 @@ pub fn run(opt: Opt) -> anyhow::Result<()> {
|
|||||||
let mut wtxn = index_cloned.write_txn()?;
|
let mut wtxn = index_cloned.write_txn()?;
|
||||||
let mut builder = update_builder.settings(&mut wtxn, &index_cloned);
|
let mut builder = update_builder.settings(&mut wtxn, &index_cloned);
|
||||||
|
|
||||||
|
// We transpose the settings JSON struct into a real setting update.
|
||||||
|
if let Some(names) = settings.searchable_attributes {
|
||||||
|
match names {
|
||||||
|
Some(names) => builder.set_searchable_fields(names),
|
||||||
|
None => builder.reset_searchable_fields(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// We transpose the settings JSON struct into a real setting update.
|
// We transpose the settings JSON struct into a real setting update.
|
||||||
if let Some(names) = settings.displayed_attributes {
|
if let Some(names) = settings.displayed_attributes {
|
||||||
match names {
|
match names {
|
||||||
|
Loading…
Reference in New Issue
Block a user