From 4874c8f6ad9750eb5275da1a194a00d0a7739003 Mon Sep 17 00:00:00 2001 From: meili-bot <74670311+meili-bot@users.noreply.github.com> Date: Mon, 29 Aug 2022 20:00:24 +0200 Subject: [PATCH 1/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dd948de0..9c3e60a2 100644 --- a/README.md +++ b/README.md @@ -242,7 +242,7 @@ WARNING: `meilisearch-sdk` will panic if no Window is available (ex: Web extensi ## 🤖 Compatibility with Meilisearch -This package only guarantees the compatibility with the [version v0.27.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.27.0). +This package only guarantees the compatibility with the [version v0.29.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.29.0). ## ⚙️ Development Workflow and Contributing From 128daacc7a2152ff3b1c9708fa659cefab2eb55c Mon Sep 17 00:00:00 2001 From: meili-bot <74670311+meili-bot@users.noreply.github.com> Date: Mon, 29 Aug 2022 20:00:25 +0200 Subject: [PATCH 2/4] Update README.tpl --- README.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.tpl b/README.tpl index 04e98565..722055b9 100644 --- a/README.tpl +++ b/README.tpl @@ -97,7 +97,7 @@ WARNING: `meilisearch-sdk` will panic if no Window is available (ex: Web extensi ## 🤖 Compatibility with Meilisearch -This package only guarantees the compatibility with the [version v0.27.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.27.0). +This package only guarantees the compatibility with the [version v0.29.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.29.0). ## ⚙️ Development Workflow and Contributing From eb18ed97fa9d5f683678085bb5f1c06ad5acb7c0 Mon Sep 17 00:00:00 2001 From: cvermand <33010418+bidoubiwa@users.noreply.github.com> Date: Mon, 5 Sep 2022 17:12:17 +0200 Subject: [PATCH 3/4] Update search params for v0.29.0 (#333) * Add MatchingStrategies as an enum * Improve example --- src/search.rs | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/search.rs b/src/search.rs index 219310a5..6baf58ec 100644 --- a/src/search.rs +++ b/src/search.rs @@ -9,6 +9,14 @@ pub struct MatchRange { pub length: usize, } +#[derive(Debug, Clone, Serialize)] +pub enum MatchingStrategies { + #[serde(rename = "all")] + ALL, + #[serde(rename = "last")] + LAST, +} + /// A single result. /// Contains the complete object, optionally the formatted object, and optionally an object that contains information about the matches. #[derive(Deserialize, Debug)] @@ -234,6 +242,10 @@ pub struct Query<'a> { /// Default: `false` #[serde(skip_serializing_if = "Option::is_none")] pub show_matches_position: Option, + + /// Defines the strategy on how to handle queries containing multiple words. + #[serde(skip_serializing_if = "Option::is_none")] + pub matching_strategy: Option, } #[allow(missing_docs)] @@ -255,6 +267,7 @@ impl<'a> Query<'a> { highlight_pre_tag: None, highlight_post_tag: None, show_matches_position: None, + matching_strategy: None, } } pub fn with_query<'b>(&'b mut self, query: &'a str) -> &'b mut Query<'a> { @@ -332,6 +345,13 @@ impl<'a> Query<'a> { self.show_matches_position = Some(show_matches_position); self } + pub fn with_matching_strategy<'b>( + &'b mut self, + matching_strategy: MatchingStrategies, + ) -> &'b mut Query<'a> { + self.matching_strategy = Some(matching_strategy); + self + } pub fn build(&mut self) -> Query<'a> { self.clone() } @@ -755,6 +775,36 @@ mod tests { Ok(()) } + #[meilisearch_test] + async fn test_matching_strategy_all(client: Client, index: Index) -> Result<(), Error> { + setup_test_index(&client, &index).await?; + + let results = Query::new(&index) + .with_query("Harry Styles") + .with_matching_strategy(MatchingStrategies::ALL) + .execute::() + .await + .unwrap(); + + assert_eq!(results.hits.len(), 0); + Ok(()) + } + + #[meilisearch_test] + async fn test_matching_strategy_left(client: Client, index: Index) -> Result<(), Error> { + setup_test_index(&client, &index).await?; + + let results = Query::new(&index) + .with_query("Harry Styles") + .with_matching_strategy(MatchingStrategies::LAST) + .execute::() + .await + .unwrap(); + + assert_eq!(results.hits.len(), 7); + Ok(()) + } + #[meilisearch_test] async fn test_generate_tenant_token_from_client( client: Client, From f84631bf4bc3975062319d2ea0e6ea2c52a4cd83 Mon Sep 17 00:00:00 2001 From: Charlotte Vermandel Date: Mon, 3 Oct 2022 17:15:51 +0200 Subject: [PATCH 4/4] Update Query type to SearchQuery --- src/search.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/search.rs b/src/search.rs index 41590794..a2f0abb3 100644 --- a/src/search.rs +++ b/src/search.rs @@ -287,7 +287,10 @@ impl<'a> SearchQuery<'a> { self.filter = Some(filter); self } - pub fn with_facets<'b>(&'b mut self, facets: Selectors<&'a [&'a str]>) -> &'b mut SearchQuery<'a> { + pub fn with_facets<'b>( + &'b mut self, + facets: Selectors<&'a [&'a str]>, + ) -> &'b mut SearchQuery<'a> { self.facets = Some(facets); self } @@ -778,7 +781,7 @@ mod tests { async fn test_matching_strategy_all(client: Client, index: Index) -> Result<(), Error> { setup_test_index(&client, &index).await?; - let results = Query::new(&index) + let results = SearchQuery::new(&index) .with_query("Harry Styles") .with_matching_strategy(MatchingStrategies::ALL) .execute::() @@ -793,7 +796,7 @@ mod tests { async fn test_matching_strategy_left(client: Client, index: Index) -> Result<(), Error> { setup_test_index(&client, &index).await?; - let results = Query::new(&index) + let results = SearchQuery::new(&index) .with_query("Harry Styles") .with_matching_strategy(MatchingStrategies::LAST) .execute::()