Skip to content

Commit 834dd4f

Browse files
committed
Add test to cover schema Fields
1 parent fac2314 commit 834dd4f

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

tests/NRedisStack.Tests/Search/SearchTests.cs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,61 @@ public async Task TestFiltersAsync()
15051505
Assert.Equal( "doc1" , res1.Documents[0].Id);
15061506
}
15071507

1508+
[Fact]
1509+
public void TestFieldsCommandBuilder()
1510+
{
1511+
IDatabase db = redisFixture.Redis.GetDatabase();
1512+
db.Execute("FLUSHALL");
1513+
var ft = db.FT();
1514+
// Create the index with the same fields as in the original test
1515+
var sc = new Schema()
1516+
.AddTextField("txt", 1.0, true, true, true, "dm:en", true, true)
1517+
.AddNumericField("num", true, true)
1518+
.AddGeoField("loc", true, true)
1519+
.AddTagField("tag",true,true, true, ";", true, true)
1520+
.AddVectorField("vec", VectorField.VectorAlgo.FLAT, null);
1521+
var buildCommand = SearchCommandBuilder.Create("idx", new FTCreateParams(), sc);
1522+
var expectedArgs = new List<object> {
1523+
"idx",
1524+
"SCHEMA",
1525+
"txt",
1526+
"TEXT",
1527+
"SORTABLE",
1528+
"UNF",
1529+
"NOSTEM",
1530+
"NOINDEX",
1531+
"PHONETIC",
1532+
"dm:en",
1533+
"WITHSUFFIXTRIE",
1534+
"num",
1535+
"NUMERIC",
1536+
"SORTABLE",
1537+
"NOINDEX",
1538+
"loc",
1539+
"GEO",
1540+
"SORTABLE",
1541+
"NOINDEX",
1542+
"tag",
1543+
"TAG",
1544+
"SORTABLE",
1545+
"UNF",
1546+
"NOINDEX",
1547+
"WITHSUFFIXTRIE",
1548+
"SEPARATOR",
1549+
";",
1550+
"CASESENSITIVE",
1551+
"vec",
1552+
"VECTOR",
1553+
"FLAT"
1554+
};
1555+
1556+
Assert.Equal("FT.CREATE", buildCommand.Command);
1557+
for(int i = 0; i < expectedArgs.Count; i++)
1558+
{
1559+
Assert.Equal(expectedArgs[i], buildCommand.Args[i]);
1560+
}
1561+
}
1562+
15081563
[Fact]
15091564
public void TestModulePrefixs1()
15101565
{

0 commit comments

Comments
 (0)