Skip to content

Commit e1ba052

Browse files
Address review feedback
1 parent 0247ac1 commit e1ba052

File tree

7 files changed

+58
-42
lines changed

7 files changed

+58
-42
lines changed

src/Meilisearch/Converters/EmbedderSourceConverter.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ public override EmbedderSource Read(ref Utf8JsonReader reader, Type typeToConver
1515
{
1616
return embedderSource;
1717
}
18+
19+
throw new JsonException($"Invalid EmbedderSource value: '{enumValue}'.");
1820
}
1921

20-
return EmbedderSource.Unknown;
22+
throw new JsonException($"Expected string for EmbedderSource, but found {reader.TokenType}.");
2123
}
2224

2325
public override void Write(Utf8JsonWriter writer, EmbedderSource value, JsonSerializerOptions options)
@@ -40,7 +42,6 @@ public override void Write(Utf8JsonWriter writer, EmbedderSource value, JsonSeri
4042
case EmbedderSource.UserProvided:
4143
source = "userProvided";
4244
break;
43-
case EmbedderSource.Unknown:
4445
default:
4546
throw new ArgumentOutOfRangeException(nameof(value), value, null);
4647
}

src/Meilisearch/Embedder.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using System.Collections.Generic;
32
using System.Text.Json.Serialization;
43

src/Meilisearch/EmbedderDistribution.cs

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,55 @@ namespace Meilisearch
88
/// </summary>
99
public class EmbedderDistribution
1010
{
11+
private double _mean;
12+
private double _sigma;
13+
1114
/// <summary>
1215
/// Creates a new instance of <see cref="EmbedderDistribution"/>.
1316
/// </summary>
1417
/// <param name="mean">Mean value between 0 and 1.</param>
1518
/// <param name="sigma">Sigma value between 0 and 1.</param>
16-
/// <exception cref="ArgumentOutOfRangeException"></exception>
1719
public EmbedderDistribution(double mean, double sigma)
1820
{
19-
if (mean < 0 || mean > 1)
20-
{
21-
throw new ArgumentOutOfRangeException(nameof(mean), "Mean must be between 0 and 1.");
22-
}
23-
24-
if (sigma < 0 || sigma > 1)
25-
{
26-
throw new ArgumentOutOfRangeException(nameof(sigma), "Sigma must be between 0 and 1.");
27-
}
21+
Mean = mean;
22+
Sigma = sigma;
2823
}
2924

3025
/// <summary>
3126
/// Gets or sets the mean.
3227
/// </summary>
3328
[JsonPropertyName("mean")]
34-
public double Mean { get; set; }
29+
public double Mean
30+
{
31+
get => _mean;
32+
set
33+
{
34+
if (value < 0 || value > 1)
35+
{
36+
throw new ArgumentOutOfRangeException(nameof(Mean), "Mean must be between 0 and 1.");
37+
}
38+
39+
_mean = value;
40+
}
41+
}
3542

3643
/// <summary>
3744
/// Gets or sets the sigma.
3845
/// </summary>
3946
[JsonPropertyName("sigma")]
40-
public double Sigma { get; set; }
47+
public double Sigma
48+
{
49+
get => _sigma;
50+
set
51+
{
52+
if (value < 0 || value > 1)
53+
{
54+
throw new ArgumentOutOfRangeException(nameof(Sigma), "Sigma must be between 0 and 1.");
55+
}
56+
57+
_sigma = value;
58+
}
59+
}
4160

4261
/// <summary>
4362
/// Creates a new instance of <see cref="EmbedderDistribution"/> with a uniform distribution.

src/Meilisearch/EmbedderSource.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,5 @@ public enum EmbedderSource
3434
/// User-provided
3535
/// </summary>
3636
UserProvided,
37-
38-
/// <summary>
39-
/// Unknown
40-
/// </summary>
41-
Unknown
4237
}
4338
}

src/Meilisearch/SimilarDocumentsQuery.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public SimilarDocumentsQuery(string id)
3838
/// Gets or sets the attributes to retrieve.
3939
/// </summary>
4040
[JsonPropertyName("attributesToRetrieve")]
41-
public string[] AttributesToRetrieve { get; set; } = { "*" };
41+
public string[] AttributesToRetrieve { get; set; } = new[] { "*" };
4242

4343
/// <summary>
4444
/// Gets or sets the offset.
@@ -74,7 +74,7 @@ public SimilarDocumentsQuery(string id)
7474
/// Gets or sets the ranking score threshold.
7575
/// </summary>
7676
[JsonPropertyName("rankingScoreThreshold")]
77-
public int? RankingScoreThreshold { get; set; }
77+
public decimal? RankingScoreThreshold { get; set; }
7878

7979
/// <summary>
8080
/// Gets or sets whether to retrieve the vectors.

src/Meilisearch/SimilarDocumentsResult.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,31 @@ public SimilarDocumentsResult(
4040
public IReadOnlyCollection<T> Hits { get; }
4141

4242
/// <summary>
43-
/// Gets or sets the id.
43+
/// Gets the id.
4444
/// </summary>
4545
[JsonPropertyName("id")]
4646
public string Id { get; }
4747

4848
/// <summary>
49-
/// Gets or sets the processing time in milliseconds.
49+
/// Gets the processing time in milliseconds.
5050
/// </summary>
5151
[JsonPropertyName("processingTimeMs")]
5252
public int ProcessingTimeMs { get; }
5353

5454
/// <summary>
55-
/// Gets or sets the offset.
55+
/// Gets the offset.
5656
/// </summary>
5757
[JsonPropertyName("offset")]
5858
public int Offset { get; }
5959

6060
/// <summary>
61-
/// Gets or sets the limit.
61+
/// Gets the limit.
6262
/// </summary>
6363
[JsonPropertyName("limit")]
6464
public int Limit { get; }
6565

6666
/// <summary>
67-
/// Gets or sets the estimated total hits.
67+
/// Gets the estimated total hits.
6868
/// </summary>
6969
[JsonPropertyName("estimatedTotalHits")]
7070
public int EstimatedTotalHits { get; }

tests/Meilisearch.Tests/Meilisearch.Tests.csproj

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,35 @@
66
</PropertyGroup>
77

88
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
9-
<NoWarn>1701;1702;CA1861</NoWarn>
9+
<NoWarn>1701;1702;CA1861</NoWarn>
1010
</PropertyGroup>
1111

1212
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
13-
<NoWarn>1701;1702;CA1861</NoWarn>
13+
<NoWarn>1701;1702;CA1861</NoWarn>
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="FluentAssertions" Version="7.0.0" />
18-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
19-
<PackageReference Include="xunit" Version="2.7.0" />
20-
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2" />
17+
<PackageReference Include="FluentAssertions" Version="7.0.0"/>
18+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0"/>
19+
<PackageReference Include="xunit" Version="2.7.0"/>
20+
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2"/>
2121
</ItemGroup>
2222

2323
<ItemGroup>
24-
<ProjectReference Include="..\..\src\Meilisearch\Meilisearch.csproj" />
24+
<ProjectReference Include="..\..\src\Meilisearch\Meilisearch.csproj"/>
2525
</ItemGroup>
2626

2727
<ItemGroup>
28-
<None Update="Datasets\small_movies.json" CopyToOutputDirectory="PreserveNewest" />
29-
<None Update="Datasets\songs.csv" CopyToOutputDirectory="PreserveNewest" />
30-
<None Update="Datasets\songs_custom_delimiter.csv" CopyToOutputDirectory="PreserveNewest" />
31-
<None Update="Datasets\songs.ndjson" CopyToOutputDirectory="PreserveNewest" />
32-
<None Update="Datasets\movies_with_string_id.json" CopyToOutputDirectory="PreserveNewest" />
33-
<None Update="Datasets\movies_for_faceting.json" CopyToOutputDirectory="PreserveNewest" />
34-
<None Update="Datasets\movies_with_int_id.json" CopyToOutputDirectory="PreserveNewest" />
35-
<None Update="Datasets\movies_with_info.json" CopyToOutputDirectory="PreserveNewest" />
28+
<None Update="Datasets\movies_for_faceting.json" CopyToOutputDirectory="PreserveNewest"/>
29+
<None Update="Datasets\movies_for_vector.json" CopyToOutputDirectory="PreserveNewest"/>
30+
<None Update="Datasets\movies_with_info.json" CopyToOutputDirectory="PreserveNewest"/>
31+
<None Update="Datasets\movies_with_int_id.json" CopyToOutputDirectory="PreserveNewest"/>
32+
<None Update="Datasets\movies_with_string_id.json" CopyToOutputDirectory="PreserveNewest"/>
33+
<None Update="Datasets\products_for_distinct_search.json" CopyToOutputDirectory="PreserveNewest"/>
34+
<None Update="Datasets\small_movies.json" CopyToOutputDirectory="PreserveNewest"/>
35+
<None Update="Datasets\songs.csv" CopyToOutputDirectory="PreserveNewest"/>
36+
<None Update="Datasets\songs.ndjson" CopyToOutputDirectory="PreserveNewest"/>
37+
<None Update="Datasets\songs_custom_delimiter.csv" CopyToOutputDirectory="PreserveNewest"/>
3638
</ItemGroup>
3739

3840
</Project>

0 commit comments

Comments
 (0)