Skip to content

Commit 6ad4048

Browse files
authored
Test for supporting INT8 and UINT8 vector types (#399)
test with INT8 and UINT8 vector types
1 parent a1dd0d8 commit 6ad4048

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/NRedisStack.Tests/Search/IndexCreationTests.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,40 @@ public void TestCreateFloat16VectorField(string endpointId)
166166
res = ft.Search("idx", q.AddParam("vec", vec2ToBytes));
167167
Assert.Equal(2, res.TotalResults);
168168
}
169+
170+
[SkipIfRedis(Comparison.LessThan, "7.9.0")]
171+
[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))]
172+
public void TestCreateInt8VectorField(string endpointId)
173+
{
174+
IDatabase db = GetCleanDatabase(endpointId);
175+
var ft = db.FT(2);
176+
var schema = new Schema().AddVectorField("v", Schema.VectorField.VectorAlgo.FLAT, new Dictionary<string, object>()
177+
{
178+
["TYPE"] = "INT8",
179+
["DIM"] = "5",
180+
["DISTANCE_METRIC"] = "L2",
181+
}).AddVectorField("v2", Schema.VectorField.VectorAlgo.FLAT, new Dictionary<string, object>()
182+
{
183+
["TYPE"] = "UINT8",
184+
["DIM"] = "4",
185+
["DISTANCE_METRIC"] = "L2",
186+
});
187+
Assert.True(ft.Create("idx", new FTCreateParams(), schema));
188+
189+
byte[] vec1 = new byte[] { 2, 1, 2, 2, 2 };
190+
byte[] vec2 = new byte[] { 1, 2, 2, 2 };
191+
192+
var entries = new HashEntry[] { new HashEntry("v", vec1), new HashEntry("v2", vec2) };
193+
db.HashSet("a", entries);
194+
db.HashSet("b", entries);
195+
db.HashSet("c", entries);
196+
197+
var q = new Query("*=>[KNN 2 @v $vec]").ReturnFields("__v_score");
198+
var res = ft.Search("idx", q.AddParam("vec", vec1));
199+
Assert.Equal(2, res.TotalResults);
200+
201+
q = new Query("*=>[KNN 2 @v2 $vec]").ReturnFields("__v_score");
202+
res = ft.Search("idx", q.AddParam("vec", vec2));
203+
Assert.Equal(2, res.TotalResults);
204+
}
169205
}

0 commit comments

Comments
 (0)