mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 03:55:07 +08:00
Fix loading of dump v2 by patching ranking rules inside update settings
This commit is contained in:
parent
496a27f4a2
commit
73845f87cf
@ -78,11 +78,17 @@ fn patch_updates(dir: impl AsRef<Path>, path: impl AsRef<Path>) -> anyhow::Resul
|
|||||||
let mut output_update_file = NamedTempFile::new_in(&dir)?;
|
let mut output_update_file = NamedTempFile::new_in(&dir)?;
|
||||||
let update_file = File::open(&path)?;
|
let update_file = File::open(&path)?;
|
||||||
|
|
||||||
let stream = Deserializer::from_reader(update_file).into_iter::<v2::UpdateEntry>();
|
let updates = Deserializer::from_reader(update_file).into_iter::<serde_json::Value>();
|
||||||
|
for update_entry in updates {
|
||||||
for update in stream {
|
let mut update_entry = update_entry?;
|
||||||
let update_entry = update?;
|
println!("{:?}", update_entry);
|
||||||
|
|
||||||
|
// We first deserialize the dump meta into a serde_json::Value and change
|
||||||
|
// the custom ranking rules settings from the old format to the new format.
|
||||||
|
if let Some(ranking_rules) = update_entry.pointer_mut("/update/meta/rankingRules") {
|
||||||
|
patch_custom_ranking_rules(ranking_rules);
|
||||||
|
}
|
||||||
|
let update_entry: v2::UpdateEntry = serde_json::from_value(update_entry)?;
|
||||||
let update_entry = v3::UpdateEntry::from(update_entry);
|
let update_entry = v3::UpdateEntry::from(update_entry);
|
||||||
|
|
||||||
serde_json::to_writer(&mut output_update_file, &update_entry)?;
|
serde_json::to_writer(&mut output_update_file, &update_entry)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user