From 5dffe566fd59a5cdc6d40df9f8dc0b5328cc2a97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Urquizar?= Date: Mon, 14 Jun 2021 18:40:15 +0200 Subject: [PATCH] Remove useless comments --- meilisearch-http/src/index/search.rs | 86 +--------------------------- 1 file changed, 1 insertion(+), 85 deletions(-) diff --git a/meilisearch-http/src/index/search.rs b/meilisearch-http/src/index/search.rs index 1d834234b..37aea6248 100644 --- a/meilisearch-http/src/index/search.rs +++ b/meilisearch-http/src/index/search.rs @@ -1,4 +1,3 @@ -// use std::borrow::Cow; use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; use std::time::Instant; @@ -207,82 +206,13 @@ impl Index { .cloned() .collect::>(); - // All attributes present in `_formatted` that are not necessary highighted or croped + // All attributes present in `_formatted` that are not necessary highighted or cropped let ids_in_formatted = formatted_ids .union(&to_retrieve_ids) .cloned() .sorted() .collect::>(); - - // let to_highlight_ids = query // PLUS BESOIN - // .attributes_to_highlight - // .as_ref() - // .map(fids) - // .unwrap_or_default(); - - - // let to_crop_ids_length = query - // .attributes_to_crop - // .as_ref() - // .map(|attributes: &Vec| { - // let mut ids_length_crop = HashMap::new(); - // for attribute in attributes { - // let mut attr_name = attribute.clone(); - // let mut attr_len = Some(query.crop_length); - - // if attr_name.contains(':') { - // let mut split = attr_name.rsplit(':'); - // attr_len = match split.next() { - // Some(s) => s.parse::().ok(), - // None => None, - // }; - // attr_name = split.flat_map(|s| s.chars()).collect(); - // } - - // if attr_name == "*" { - // let ids = displayed_ids.clone(); - // for id in ids { - // ids_length_crop.insert(id, attr_len); - // } - // } - - // if let Some(id) = fields_ids_map.id(&attr_name) { - // if displayed_ids.contains(&id) { - // ids_length_crop.insert(id, attr_len); - // } - // } - // } - // ids_length_crop - // }) - // .unwrap_or_default(); - - // let to_crop_ids = to_crop_ids_length // PLUS BESOIN - // .clone() - // .into_iter() - // .map(|(k, _)| k) - // .collect::>(); - - // The formatted attributes are: - // - The one in either highlighted attributes or cropped attributes if there are attributes - // to retrieve - // - All the attributes to retrieve if there are either highlighted or cropped attributes - // the request specified that all attributes are to retrieve (i.e attributes to retrieve is - // empty in the query) - // let all_formatted = if query.attributes_to_retrieve.is_none() { - // if query.attributes_to_highlight.is_some() || query.attributes_to_crop.is_some() { - // Cow::Borrowed(&all_attributes) - // } else { - // Cow::Owned(Vec::new()) - // } - // } else { - // let attrs = (&to_crop_ids | &to_highlight_ids) - // .intersection(&displayed_ids) - // .cloned() - // .collect::>(); - // Cow::Owned(attrs) - // }; - let stop_words = fst::Set::default(); let formatter = Formatter::new(&stop_words, (String::from(""), String::from(""))); @@ -295,10 +225,7 @@ impl Index { &formatter, &matching_words, &ids_in_formatted, - // all_formatted.as_ref().as_slice(), &formatted_options, - // &to_highlight_ids, //ICI - // &to_crop_ids_length, //ICI )?; let hit = SearchHit { document, @@ -364,8 +291,6 @@ fn compute_formatted>( matching_words: &impl Matcher, ids_in_formatted: &[FieldId], formatted_options: &HashMap, - // to_highlight_fields: &HashSet, //ICI - // to_crop_fields: &HashMap>, //ICI ) -> anyhow::Result { let mut document = Document::new(); @@ -380,8 +305,6 @@ fn compute_formatted>( matching_words, format.highlight, format.crop, - // to_crop_fields.get(field).copied().flatten(), //ICI - // to_highlight_fields.contains(field), //ICI ); } @@ -405,12 +328,6 @@ trait Matcher { fn matches(&self, w: &str) -> Option; } -// #[cfg(test)] -// impl Matcher for HashSet { -// fn matches(&self, w: &str) -> bool { -// self.contains(w) -// } -// } #[cfg(test)] impl Matcher for HashMap<&str, Option> { fn matches(&self, w: &str) -> Option { @@ -681,7 +598,6 @@ mod test { let mut formatted_options = HashMap::new(); formatted_options.insert(title, FormatOptions { highlight: true, crop: None }); - // let matching_words = HashSet::from_iter(Some(String::from("hobbit"))); let mut matching_words = HashMap::new(); matching_words.insert("hobbit", Some(6));