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
8 changes: 7 additions & 1 deletion .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -738,9 +738,15 @@ search_parameter_guide_matching_strategy_1: |-
search_parameter_guide_matching_strategy_2: |-
SearchQuery params = new SearchQuery() { MatchingStrategy = "all" };
await client.Index("movies").SearchAsync<Game>("big fat liar", params);
search_parameter_guide_show_ranking_score_1: |-
var params = new SearchQuery()
{
ShowRankingScore = true
};
await client.Index("movies").SearchAsync<MovieWithRankingScore>("dragon", params);
get_proximity_precision_settings_1: |-
await client.Index("books").GetProximityPrecisionAsync();
update_proximity_precision_settings_1: |-
await client.Index("books").UpdateProximityPrecisionAsync("byAttribute");
reset_proximity_precision_settings_1: |-
await client.Index("books").ResetProximityPrecisionAsync();
await client.Index("books").ResetProximityPrecisionAsync();
6 changes: 6 additions & 0 deletions src/Meilisearch/SearchQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ public class SearchQuery
[JsonPropertyName("matchingStrategy")]
public string MatchingStrategy { get; set; }

/// <summary>
/// Gets or sets showRankingScore parameter. It defines wheter the global ranking score of a document (between 0 and 1) is returned or not.
/// </summary>
[JsonPropertyName("showRankingScore")]
public bool? ShowRankingScore { get; set; }

// pagination:

/// <summary>
Expand Down
10 changes: 10 additions & 0 deletions tests/Meilisearch.Tests/Movie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,14 @@ public class FormattedMovie
#pragma warning disable SA1300
public Movie _Formatted { get; set; }
}

public class MovieWithRankingScore
{
public string Id { get; set; }

public string Name { get; set; }

public string Genre { get; set; }
public double? _RankingScore { get; set; }
}
}
11 changes: 11 additions & 0 deletions tests/Meilisearch.Tests/SearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -492,5 +492,16 @@ public async Task CustomSearchWithMatchingStrategyLast()

Assert.True(movies.Hits.Count() > 1);
}

[Fact]
public async Task CustomSearchWithShowRankingScore()
{
var searchQuery = new SearchQuery()
{
ShowRankingScore = true
};
var movies = await _basicIndex.SearchAsync<MovieWithRankingScore>("iron man", searchQuery);
Assert.NotNull(movies.Hits.First()._RankingScore);
}
}
}