Skip to content

Commit f755e7a

Browse files
committed
fixins
1 parent e0b959d commit f755e7a

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/StackExchange.Redis/VectorSetSimilaritySearchMessage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private enum VsimFlags
5353

5454
private int GetArgCount(bool useFp32)
5555
{
56-
int argCount = 2; // {key} and "ELE {member}", "FP32 {vector}" or "VALUES {num}"
56+
int argCount = 3; // {key} and "ELE {member}", "FP32 {vector}" or "VALUES {num}"
5757
if (member.IsNull && !useFp32)
5858
{
5959
argCount += vector.Length; // {vector} in the VALUES case

tests/StackExchange.Redis.Tests/VectorSetIntegrationTests.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,14 @@ public async Task VectorSetGetLinks()
424424
using var links = await db.VectorSetGetLinksAsync(key, "element1");
425425

426426
Assert.NotNull(links);
427+
foreach (var link in links.Span)
428+
{
429+
Log(link.ToString());
430+
}
431+
427432
var linksArray = links.Span.ToArray();
428433

429-
// Should contain the other elements
430-
Assert.Equal(2, linksArray.Length);
434+
// Should contain the other elements (note there can be transient duplicates, so: contains, not exact)
431435
Assert.Contains("element2", linksArray);
432436
Assert.Contains("element3", linksArray);
433437
}
@@ -469,12 +473,11 @@ public async Task VectorSetGetLinksWithScores()
469473
Assert.True(link.Score >= 0.0); // Similarity scores should be non-negative
470474
});
471475

472-
// Should contain the other elements
473-
Assert.Equal(2, linksArray.Length);
476+
// Should contain the other elements (note there can be transient duplicates, so: contains, not exact)
474477
Assert.Contains(linksArray, l => l.Member == "element2");
475478
Assert.Contains(linksArray, l => l.Member == "element3");
476479

477-
Assert.True(linksArray.Single(l => l.Member == "element2").Score > 0.9); // similar
478-
Assert.True(linksArray.Single(l => l.Member == "element3").Score < 0.8); // less-so
480+
Assert.True(linksArray.First(l => l.Member == "element2").Score > 0.9); // similar
481+
Assert.True(linksArray.First(l => l.Member == "element3").Score < 0.8); // less-so
479482
}
480483
}

0 commit comments

Comments
 (0)