Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,15 @@ search_parameter_guide_matching_strategy_2: |-
.execute()
.await
.unwrap();
search_parameter_guide_matching_strategy_3: |-
let results: SearchResults<Movie> = client
.index("movies")
.search()
.with_query("white shirt")
.with_matching_strategy(MatchingStrategies::FREQUENCY)
.execute()
.await
.unwrap();
search_parameter_guide_hitsperpage_1: |-
client.index("movies").search().with_hits_per_page(15).execute().await?;
search_parameter_guide_page_1: |-
Expand Down
19 changes: 18 additions & 1 deletion src/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub enum MatchingStrategies {
ALL,
#[serde(rename = "last")]
LAST,
#[serde(rename = "frequency")]
FREQUENCY,
}

/// A single result.
Expand Down Expand Up @@ -1151,7 +1153,7 @@ mod tests {
}

#[meilisearch_test]
async fn test_matching_strategy_left(client: Client, index: Index) -> Result<(), Error> {
async fn test_matching_strategy_last(client: Client, index: Index) -> Result<(), Error> {
setup_test_index(&client, &index).await?;

let results = SearchQuery::new(&index)
Expand All @@ -1165,6 +1167,21 @@ mod tests {
Ok(())
}

#[meilisearch_test]
async fn test_matching_strategy_frequency(client: Client, index: Index) -> Result<(), Error> {
setup_test_index(&client, &index).await?;

let results = SearchQuery::new(&index)
.with_query("Harry Styles")
.with_matching_strategy(MatchingStrategies::FREQUENCY)
.execute::<Document>()
.await
.unwrap();

assert_eq!(results.hits.len(), 7);
Ok(())
}

#[meilisearch_test]
async fn test_generate_tenant_token_from_client(
client: Client,
Expand Down