From 73918d803c74448e66ece8f573f4d1e8fdc68461 Mon Sep 17 00:00:00 2001 From: qdequele Date: Thu, 2 Jan 2020 18:31:46 +0100 Subject: [PATCH] Rename AttributesToSearchIn into SearchableAttributes; fix #428 --- meilisearch-http/src/helpers/meilisearch.rs | 14 +++++++------- meilisearch-http/src/routes/search.rs | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/meilisearch-http/src/helpers/meilisearch.rs b/meilisearch-http/src/helpers/meilisearch.rs index 668c53328..6b4380eef 100644 --- a/meilisearch-http/src/helpers/meilisearch.rs +++ b/meilisearch-http/src/helpers/meilisearch.rs @@ -77,7 +77,7 @@ impl IndexSearchExt for Index { limit: 20, attributes_to_crop: None, attributes_to_retrieve: None, - attributes_to_search_in: None, + searchable_attributes: None, attributes_to_highlight: None, filters: None, timeout: Duration::from_millis(30), @@ -93,7 +93,7 @@ pub struct SearchBuilder<'a> { limit: usize, attributes_to_crop: Option>, attributes_to_retrieve: Option>, - attributes_to_search_in: Option>, + searchable_attributes: Option>, attributes_to_highlight: Option>, filters: Option, timeout: Duration, @@ -127,14 +127,14 @@ impl<'a> SearchBuilder<'a> { self } - pub fn attributes_to_search_in(&mut self, value: HashSet) -> &SearchBuilder { - self.attributes_to_search_in = Some(value); + pub fn searchable_attributes(&mut self, value: HashSet) -> &SearchBuilder { + self.searchable_attributes = Some(value); self } pub fn add_attribute_to_search_in(&mut self, value: String) -> &SearchBuilder { - let attributes_to_search_in = self.attributes_to_search_in.get_or_insert(HashSet::new()); - attributes_to_search_in.insert(value); + let searchable_attributes = self.searchable_attributes.get_or_insert(HashSet::new()); + searchable_attributes.insert(value); self } @@ -177,7 +177,7 @@ impl<'a> SearchBuilder<'a> { }; // Filter searchable fields - if let Some(fields) = &self.attributes_to_search_in { + if let Some(fields) = &self.searchable_attributes { for attribute in fields.iter().filter_map(|f| schema.attribute(f)) { query_builder.add_searchable_attribute(attribute.0); } diff --git a/meilisearch-http/src/routes/search.rs b/meilisearch-http/src/routes/search.rs index 69dd01f09..aa3afe40e 100644 --- a/meilisearch-http/src/routes/search.rs +++ b/meilisearch-http/src/routes/search.rs @@ -20,7 +20,7 @@ struct SearchQuery { offset: Option, limit: Option, attributes_to_retrieve: Option, - attributes_to_search_in: Option, + searchable_attributes: Option, attributes_to_crop: Option, crop_length: Option, attributes_to_highlight: Option, @@ -60,8 +60,8 @@ pub async fn search_with_url_query(ctx: Context) -> SResult { search_builder.add_retrievable_field(attr.to_string()); } } - if let Some(attributes_to_search_in) = query.attributes_to_search_in { - for attr in attributes_to_search_in.split(',') { + if let Some(searchable_attributes) = query.searchable_attributes { + for attr in searchable_attributes.split(',') { search_builder.add_attribute_to_search_in(attr.to_string()); } } @@ -126,7 +126,7 @@ struct SearchMultiBody { offset: Option, limit: Option, attributes_to_retrieve: Option>, - attributes_to_search_in: Option>, + searchable_attributes: Option>, attributes_to_crop: Option>, attributes_to_highlight: Option>, filters: Option, @@ -189,8 +189,8 @@ pub async fn search_multi_index(mut ctx: Context) -> SResult { if let Some(attributes_to_retrieve) = par_body.attributes_to_retrieve.clone() { search_builder.attributes_to_retrieve(attributes_to_retrieve); } - if let Some(attributes_to_search_in) = par_body.attributes_to_search_in.clone() { - search_builder.attributes_to_search_in(attributes_to_search_in); + if let Some(searchable_attributes) = par_body.searchable_attributes.clone() { + search_builder.searchable_attributes(searchable_attributes); } if let Some(attributes_to_crop) = par_body.attributes_to_crop.clone() { search_builder.attributes_to_crop(attributes_to_crop);