From bfd81ce050c6f0723f7322300958a0834529bcf6 Mon Sep 17 00:00:00 2001 From: ad hoc Date: Wed, 30 Mar 2022 16:08:20 +0200 Subject: [PATCH] add exact atttributes to cli settings --- cli/src/main.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cli/src/main.rs b/cli/src/main.rs index 503b02887..6523cef2e 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -1,4 +1,4 @@ -use std::collections::BTreeMap; +use std::collections::{BTreeMap, HashSet}; use std::fs::File; use std::io::{stdin, BufRead, BufReader, Cursor, Read, Write}; use std::path::PathBuf; @@ -99,8 +99,10 @@ impl Settings { }) .collect(); + let exact_attributes = index.exact_attributes(&txn)?; + println!( - "displayed attributes:\n\t{}\nsearchable attributes:\n\t{}\nfilterable attributes:\n\t{}\nsortable attributes:\n\t{}\ncriterion:\n\t{}\nstop words:\n\t{}\ndistinct fields:\n\t{}\nsynonyms:\n\t{}\n", + "displayed attributes:\n\t{}\nsearchable attributes:\n\t{}\nfilterable attributes:\n\t{}\nsortable attributes:\n\t{}\ncriterion:\n\t{}\nstop words:\n\t{}\ndistinct fields:\n\t{}\nsynonyms:\n\t{}\nexact attributes:\n{}", displayed_attributes.unwrap_or(vec!["*".to_owned()]).join("\n\t"), searchable_attributes.unwrap_or(vec!["*".to_owned()]).join("\n\t"), filterable_attributes.join("\n\t"), @@ -109,6 +111,7 @@ impl Settings { stop_words.join("\n\t"), distinct_field.unwrap_or_default(), synonyms.into_iter().map(|(k, v)| format!("\n\t{}:\n{:?}", k, v)).collect::(), + exact_attributes.join("\n\t"), ); Ok(()) } @@ -463,6 +466,8 @@ struct SettingsUpdate { filterable_attributes: Option>, #[structopt(long)] criteria: Option>, + #[structopt(long)] + exact_attributes: Option>, } impl Performer for SettingsUpdate { @@ -489,6 +494,14 @@ impl Performer for SettingsUpdate { } } + if let Some(exact_attributes) = self.exact_attributes { + if !exact_attributes.is_empty() { + update.set_exact_attributes(exact_attributes.into_iter().collect()); + } else { + update.reset_exact_attributes(); + } + } + let mut bars = Vec::new(); let progesses = MultiProgress::new(); for _ in 0..4 {