From 0eb3120b4271dcfbcfc6548dab36e5b83da9eb6b Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 1 May 2024 11:52:54 +0300 Subject: [PATCH 1/9] Change InfoResult/Attribute to Array of Arrays --- src/NRedisStack/ResponseParser.cs | 6 +++ .../Search/DataTypes/InfoResult.cs | 39 ++++++++++--------- tests/NRedisStack.Tests/Search/SearchTests.cs | 16 ++++---- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/NRedisStack/ResponseParser.cs b/src/NRedisStack/ResponseParser.cs index 0be0b169..f74f0ab3 100644 --- a/src/NRedisStack/ResponseParser.cs +++ b/src/NRedisStack/ResponseParser.cs @@ -41,6 +41,12 @@ public static RedisResult[] ToArray(this RedisResult result) throw new ArgumentNullException(nameof(redisResults)); } + public static RedisResult[][] ToArrayArray(this RedisResult result) + { + var redisResults = (RedisResult[])result!; + return redisResults.Select(x => (RedisResult[])x!).ToArray(); + } + public static long ToLong(this RedisResult result) { if ((long?)result == null) diff --git a/src/NRedisStack/Search/DataTypes/InfoResult.cs b/src/NRedisStack/Search/DataTypes/InfoResult.cs index ac39a3a8..97df721a 100644 --- a/src/NRedisStack/Search/DataTypes/InfoResult.cs +++ b/src/NRedisStack/Search/DataTypes/InfoResult.cs @@ -7,7 +7,7 @@ public class InfoResult private readonly Dictionary _all = new(); public string IndexName => GetString("index_name")!; public Dictionary IndexOption => GetRedisResultDictionary("index_options")!; - public Dictionary[] Attributes => GetRedisResultDictionaryArray("attributes")!; + public RedisResult[][] Attributes => GetRedisResultArrayArray("attributes")!; public long NumDocs => GetLong("num_docs"); public string MaxDocId => GetString("max_doc_id")!; public long NumTerms => GetLong("num_terms"); @@ -91,26 +91,29 @@ private double GetDouble(string key) } return result; - } - private Dictionary[]? GetRedisResultDictionaryArray(string key) + private RedisResult[][]? GetRedisResultArrayArray(string key) { if (!_all.TryGetValue(key, out var value)) return default; - var values = (RedisResult[])value!; - var result = new Dictionary[values.Length]; - for (int i = 0; i < values.Length; i++) - { - var fv = (RedisResult[])values[i]!; - var dict = new Dictionary(); - for (int j = 0; j < fv.Length; j += 2) - { - dict.Add((string)fv[j]!, fv[j + 1]); - } - - result[i] = dict; - } - - return result; + return value.ToArrayArray(); } + + // private Dictionary[]? GetRedisResultDictionaryArray(string key) + // { + // if (!_all.TryGetValue(key, out var value)) return default; + // var values = (RedisResult[])value!; + // var result = new Dictionary[values.Length]; + // for (int i = 0; i < values.Length; i++) + // { + // var fv = (RedisResult[])values[i]!; + // var dict = new Dictionary(); + // for (int j = 0; j < fv.Length; j += 2) + // { + // dict.Add((string)fv[j]!, fv[j + 1]); + // } + // result[i] = dict; + // } + // return result; + // } } \ No newline at end of file diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index 0376a54c..8211de07 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -702,7 +702,7 @@ public void AlterAdd() IDatabase db = redisFixture.Redis.GetDatabase(); db.Execute("FLUSHALL"); var ft = db.FT(); - Schema sc = new Schema().AddTextField("title", 1.0); + Schema sc = new Schema().AddTextField("title", 1.0, sortable: true); Assert.True(ft.Create(index, FTCreateParams.CreateParams(), sc)); @@ -733,9 +733,9 @@ public void AlterAdd() Assert.Equal(index, info.IndexName); Assert.Empty(info.IndexOption); // Assert.Equal(,info.IndexDefinition); - Assert.Equal("title", (info.Attributes[0]["identifier"]).ToString()); - Assert.Equal("TAG", (info.Attributes[1]["type"]).ToString()); - Assert.Equal("name", (info.Attributes[2]["attribute"]).ToString()); + Assert.Equal("title", info.Attributes[0][1].ToString()); + Assert.Equal("TAG", info.Attributes[1][5].ToString()); + Assert.Equal("name", info.Attributes[2][3].ToString()); Assert.Equal(100, info.NumDocs); Assert.NotNull(info.MaxDocId); Assert.Equal(102, info.NumTerms); @@ -766,7 +766,7 @@ public async Task AlterAddAsync() IDatabase db = redisFixture.Redis.GetDatabase(); db.Execute("FLUSHALL"); var ft = db.FT(); - Schema sc = new Schema().AddTextField("title", 1.0); + Schema sc = new Schema().AddTextField("title", 1.0, sortable: true); Assert.True(ft.Create(index, FTCreateParams.CreateParams(), sc)); @@ -795,9 +795,9 @@ public async Task AlterAddAsync() var info = await ft.InfoAsync(index); Assert.Equal(index, info.IndexName); - Assert.Equal("title", (info.Attributes[0]["identifier"]).ToString()); - Assert.Equal("TAG", (info.Attributes[1]["type"]).ToString()); - Assert.Equal("name", (info.Attributes[2]["attribute"]).ToString()); + Assert.Equal("title", info.Attributes[0][1].ToString()); + Assert.Equal("TAG", info.Attributes[1][5].ToString()); + Assert.Equal("name", info.Attributes[2][3].ToString()); Assert.Equal(100, info.NumDocs); Assert.Equal("300", info.MaxDocId); Assert.Equal(102, info.NumTerms); From ac1b34e9be89f2eb25306c181baba878bbd50a3e Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 8 May 2024 16:43:16 +0300 Subject: [PATCH 2/9] test with and without sortable --- tests/NRedisStack.Tests/Search/SearchTests.cs | 128 +++++++++++++++++- 1 file changed, 127 insertions(+), 1 deletion(-) diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index 8211de07..5161af7f 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -702,7 +702,7 @@ public void AlterAdd() IDatabase db = redisFixture.Redis.GetDatabase(); db.Execute("FLUSHALL"); var ft = db.FT(); - Schema sc = new Schema().AddTextField("title", 1.0, sortable: true); + Schema sc = new Schema().AddTextField("title", 1.0); Assert.True(ft.Create(index, FTCreateParams.CreateParams(), sc)); @@ -762,6 +762,132 @@ public void AlterAdd() [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] public async Task AlterAddAsync() + { + IDatabase db = redisFixture.Redis.GetDatabase(); + db.Execute("FLUSHALL"); + var ft = db.FT(); + Schema sc = new Schema().AddTextField("title", 1.0); + + Assert.True(ft.Create(index, FTCreateParams.CreateParams(), sc)); + + //sleep: + System.Threading.Thread.Sleep(2000); + + var fields = new HashEntry("title", "hello world"); + //fields.("title", "hello world"); + for (int i = 0; i < 100; i++) + { + db.HashSet($"doc{i}", fields.Name, fields.Value); + } + SearchResult res = ft.Search(index, new Query("hello world")); + Assert.Equal(100, res.TotalResults); + + Assert.True(await ft.AlterAsync(index, new Schema().AddTagField("tags").AddTextField("name", weight: 0.5))); + for (int i = 0; i < 100; i++) + { + var fields2 = new HashEntry[] { new("name", "name" + i), + new("tags", $"tagA,tagB,tag{i}") }; + // assertTrue(client.updateDocument(string.format("doc%d", i), 1.0, fields2)); + db.HashSet($"doc{i}", fields2); + } + SearchResult res2 = ft.Search(index, new Query("@tags:{tagA}")); + Assert.Equal(100, res2.TotalResults); + + var info = await ft.InfoAsync(index); + Assert.Equal(index, info.IndexName); + Assert.Equal("title", info.Attributes[0][1].ToString()); + Assert.Equal("TAG", info.Attributes[1][5].ToString()); + Assert.Equal("name", info.Attributes[2][3].ToString()); + Assert.Equal(100, info.NumDocs); + Assert.Equal("300", info.MaxDocId); + Assert.Equal(102, info.NumTerms); + Assert.True(info.NumRecords >= 200); + Assert.True(info.InvertedSzMebibytes < 1); // TODO: check this line and all the <1 lines + Assert.Equal(0, info.VectorIndexSzMebibytes); + Assert.Equal(208, info.TotalInvertedIndexBlocks); + Assert.True(info.OffsetVectorsSzMebibytes < 1); + Assert.True(info.DocTableSizeMebibytes < 1); + Assert.Equal(0, info.SortableValueSizeMebibytes); + Assert.True(info.KeyTableSizeMebibytes < 1); + Assert.Equal(8, (int)info.RecordsPerDocAvg); + Assert.True(info.BytesPerRecordAvg > 5); + Assert.True(info.OffsetsPerTermAvg > 0.8); + Assert.Equal(8, info.OffsetBitsPerRecordAvg); + Assert.Equal(0, info.HashIndexingFailures); + Assert.True(info.TotalIndexingTime > 0); + Assert.Equal(0, info.Indexing); + Assert.Equal(1, info.PercentIndexed); + Assert.Equal(4, info.NumberOfUses); + Assert.Equal(7, info.GcStats.Count); + Assert.Equal(4, info.CursorStats.Count); + } + + [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] + public void AlterAddSortable() + { + IDatabase db = redisFixture.Redis.GetDatabase(); + db.Execute("FLUSHALL"); + var ft = db.FT(); + Schema sc = new Schema().AddTextField("title", 1.0, sortable: true); + + Assert.True(ft.Create(index, FTCreateParams.CreateParams(), sc)); + + //sleep: + System.Threading.Thread.Sleep(2000); + + var fields = new HashEntry("title", "hello world"); + //fields.("title", "hello world"); + for (int i = 0; i < 100; i++) + { + db.HashSet($"doc{i}", fields.Name, fields.Value); + } + SearchResult res = ft.Search(index, new Query("hello world")); + Assert.Equal(100, res.TotalResults); + + Assert.True(ft.Alter(index, new Schema().AddTagField("tags").AddTextField("name", weight: 0.5))); + for (int i = 0; i < 100; i++) + { + var fields2 = new HashEntry[] { new("name", "name" + i), + new("tags", $"tagA,tagB,tag{i}") }; + // assertTrue(client.updateDocument(string.format("doc%d", i), 1.0, fields2)); + db.HashSet($"doc{i}", fields2); + } + SearchResult res2 = ft.Search(index, new Query("@tags:{tagA}")); + Assert.Equal(100, res2.TotalResults); + + var info = ft.Info(index); + Assert.Equal(index, info.IndexName); + Assert.Empty(info.IndexOption); + // Assert.Equal(,info.IndexDefinition); + Assert.Equal("title", info.Attributes[0][1].ToString()); + Assert.Equal("TAG", info.Attributes[1][5].ToString()); + Assert.Equal("name", info.Attributes[2][3].ToString()); + Assert.Equal(100, info.NumDocs); + Assert.NotNull(info.MaxDocId); + Assert.Equal(102, info.NumTerms); + Assert.True(info.NumRecords >= 200); + Assert.True(info.InvertedSzMebibytes < 1); // TODO: check this line and all the <1 lines + Assert.Equal(0, info.VectorIndexSzMebibytes); + Assert.Equal(208, info.TotalInvertedIndexBlocks); + Assert.True(info.OffsetVectorsSzMebibytes < 1); + Assert.True(info.DocTableSizeMebibytes < 1); + Assert.Equal(0, info.SortableValueSizeMebibytes); + Assert.True(info.KeyTableSizeMebibytes < 1); + Assert.Equal(8, (int)info.RecordsPerDocAvg); + Assert.True(info.BytesPerRecordAvg > 5); + Assert.True(info.OffsetsPerTermAvg > 0.8); + Assert.Equal(8, info.OffsetBitsPerRecordAvg); + Assert.Equal(0, info.HashIndexingFailures); + Assert.True(info.TotalIndexingTime > 0); + Assert.Equal(0, info.Indexing); + Assert.Equal(1, info.PercentIndexed); + Assert.Equal(4, info.NumberOfUses); + Assert.Equal(7, info.GcStats.Count); + Assert.Equal(4, info.CursorStats.Count); + } + + [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] + public async Task AlterAddSortableAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); db.Execute("FLUSHALL"); From 74120ba97a0984ec38c2f269ece04a74e242b14c Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 8 May 2024 16:44:32 +0300 Subject: [PATCH 3/9] remove GetRedisResultDictionaryArray --- src/NRedisStack/Search/DataTypes/InfoResult.cs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/NRedisStack/Search/DataTypes/InfoResult.cs b/src/NRedisStack/Search/DataTypes/InfoResult.cs index 97df721a..81897e51 100644 --- a/src/NRedisStack/Search/DataTypes/InfoResult.cs +++ b/src/NRedisStack/Search/DataTypes/InfoResult.cs @@ -98,22 +98,4 @@ private double GetDouble(string key) if (!_all.TryGetValue(key, out var value)) return default; return value.ToArrayArray(); } - - // private Dictionary[]? GetRedisResultDictionaryArray(string key) - // { - // if (!_all.TryGetValue(key, out var value)) return default; - // var values = (RedisResult[])value!; - // var result = new Dictionary[values.Length]; - // for (int i = 0; i < values.Length; i++) - // { - // var fv = (RedisResult[])values[i]!; - // var dict = new Dictionary(); - // for (int j = 0; j < fv.Length; j += 2) - // { - // dict.Add((string)fv[j]!, fv[j + 1]); - // } - // result[i] = dict; - // } - // return result; - // } } \ No newline at end of file From 48c416ea90b03fae4acee2707267d1f2cc050cbe Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 8 May 2024 18:05:53 +0300 Subject: [PATCH 4/9] print connection data --- .../Examples/ExampleTests.cs | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/tests/NRedisStack.Tests/Examples/ExampleTests.cs b/tests/NRedisStack.Tests/Examples/ExampleTests.cs index 40e9fd21..767fca17 100644 --- a/tests/NRedisStack.Tests/Examples/ExampleTests.cs +++ b/tests/NRedisStack.Tests/Examples/ExampleTests.cs @@ -19,6 +19,39 @@ public ExampleTests(RedisFixture redisFixture, ITestOutputHelper testOutputHelpe this.testOutputHelper = testOutputHelper; } + [Fact] + public void PrintConnectionData() + { + + var db = redisFixture.Redis.GetDatabase(); + Console.WriteLine($"************ Redis Connection Data ************"); + Console.WriteLine($"redisFixture.Redis.Configuration: {redisFixture.Redis.Configuration}"); + Console.WriteLine($"redisFixture.Redis.GetEndPoints():"); + foreach (var endpoint in redisFixture.Redis.GetEndPoints()) + { + Console.WriteLine($"endpoint: {endpoint}"); + } + Console.WriteLine($"redisFixture.Redis.GetStatus(): {redisFixture.Redis.GetStatus()}"); + Console.WriteLine($"redisFixture.Redis.GetDatabase(): {db}"); + Console.WriteLine($"redisFixture.Redis.GetDatabase().Database: {db.Database}"); + + Console.WriteLine($"PintEndPoints:"); + + var redis = db.Multiplexer; + var endpoints = db.Multiplexer.GetEndPoints(); + + foreach (var endPoint in endpoints) + { + Console.WriteLine($"EndPoint: {endPoint}"); + var server = redis.GetServer(endPoint); + Console.WriteLine($"server.IsReplica: {server.IsReplica}\n"); + + } + + Console.WriteLine($"************ End of Redis Connection Data ************"); + + } + [SkipIfRedis(Is.OSSCluster)] public void HSETandSearch() { @@ -1184,7 +1217,7 @@ public void AdvancedQueryOperationsTest() } catch { - //Todo: Check When Exception Catch + //Todo: Check When Exception Catch } Assert.True(ft.Create("vss_idx", new FTCreateParams().On(IndexDataType.HASH).Prefix("vec:"), @@ -1329,7 +1362,7 @@ public void AdvancedQueryOperationsTest() } catch { - //Todo: Check When Exception Catch + //Todo: Check When Exception Catch } Assert.True(ft.Create("wh_idx", new FTCreateParams() From f3e35364ae39a8c7ec81f5f3a2c040bada8510e4 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 8 May 2024 18:08:06 +0300 Subject: [PATCH 5/9] add is enterpeise and oss cluster to printing --- tests/NRedisStack.Tests/Examples/ExampleTests.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/NRedisStack.Tests/Examples/ExampleTests.cs b/tests/NRedisStack.Tests/Examples/ExampleTests.cs index 767fca17..93e3ceda 100644 --- a/tests/NRedisStack.Tests/Examples/ExampleTests.cs +++ b/tests/NRedisStack.Tests/Examples/ExampleTests.cs @@ -48,6 +48,10 @@ public void PrintConnectionData() } + + Console.WriteLine($"RedisFixture.isOSSCluster: {redisFixture.isOSSCluster}"); + Console.WriteLine($"RedisFixture.isEnterprise: {redisFixture.isEnterprise}"); + Console.WriteLine($"************ End of Redis Connection Data ************"); } From c7913e848a624573b5ab0033fa802dde1e5306ca Mon Sep 17 00:00:00 2001 From: shacharPash <93581407+shacharPash@users.noreply.github.com> Date: Thu, 9 May 2024 11:05:12 +0300 Subject: [PATCH 6/9] delete last commit --- .../Examples/ExampleTests.cs | 39 +------------------ 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/tests/NRedisStack.Tests/Examples/ExampleTests.cs b/tests/NRedisStack.Tests/Examples/ExampleTests.cs index 93e3ceda..fc257b98 100644 --- a/tests/NRedisStack.Tests/Examples/ExampleTests.cs +++ b/tests/NRedisStack.Tests/Examples/ExampleTests.cs @@ -19,43 +19,6 @@ public ExampleTests(RedisFixture redisFixture, ITestOutputHelper testOutputHelpe this.testOutputHelper = testOutputHelper; } - [Fact] - public void PrintConnectionData() - { - - var db = redisFixture.Redis.GetDatabase(); - Console.WriteLine($"************ Redis Connection Data ************"); - Console.WriteLine($"redisFixture.Redis.Configuration: {redisFixture.Redis.Configuration}"); - Console.WriteLine($"redisFixture.Redis.GetEndPoints():"); - foreach (var endpoint in redisFixture.Redis.GetEndPoints()) - { - Console.WriteLine($"endpoint: {endpoint}"); - } - Console.WriteLine($"redisFixture.Redis.GetStatus(): {redisFixture.Redis.GetStatus()}"); - Console.WriteLine($"redisFixture.Redis.GetDatabase(): {db}"); - Console.WriteLine($"redisFixture.Redis.GetDatabase().Database: {db.Database}"); - - Console.WriteLine($"PintEndPoints:"); - - var redis = db.Multiplexer; - var endpoints = db.Multiplexer.GetEndPoints(); - - foreach (var endPoint in endpoints) - { - Console.WriteLine($"EndPoint: {endPoint}"); - var server = redis.GetServer(endPoint); - Console.WriteLine($"server.IsReplica: {server.IsReplica}\n"); - - } - - - Console.WriteLine($"RedisFixture.isOSSCluster: {redisFixture.isOSSCluster}"); - Console.WriteLine($"RedisFixture.isEnterprise: {redisFixture.isEnterprise}"); - - Console.WriteLine($"************ End of Redis Connection Data ************"); - - } - [SkipIfRedis(Is.OSSCluster)] public void HSETandSearch() { @@ -1479,4 +1442,4 @@ private static void SortAndCompare(List expectedList, List res) Assert.Equal(expectedList[i], res[i].ToString()); } } -} \ No newline at end of file +} From f079e54fbc4ccef13575308537e7d39b81eea653 Mon Sep 17 00:00:00 2001 From: atakavci Date: Thu, 9 May 2024 18:22:02 +0300 Subject: [PATCH 7/9] effort to keep "InfoResult" backward compatible --- src/NRedisStack/ResponseParser.cs | 6 ---- .../Search/DataTypes/InfoResult.cs | 26 +++++++++++++++-- tests/NRedisStack.Tests/Search/SearchTests.cs | 28 ++++++++++--------- 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/src/NRedisStack/ResponseParser.cs b/src/NRedisStack/ResponseParser.cs index f74f0ab3..0be0b169 100644 --- a/src/NRedisStack/ResponseParser.cs +++ b/src/NRedisStack/ResponseParser.cs @@ -41,12 +41,6 @@ public static RedisResult[] ToArray(this RedisResult result) throw new ArgumentNullException(nameof(redisResults)); } - public static RedisResult[][] ToArrayArray(this RedisResult result) - { - var redisResults = (RedisResult[])result!; - return redisResults.Select(x => (RedisResult[])x!).ToArray(); - } - public static long ToLong(this RedisResult result) { if ((long?)result == null) diff --git a/src/NRedisStack/Search/DataTypes/InfoResult.cs b/src/NRedisStack/Search/DataTypes/InfoResult.cs index 81897e51..b676ca24 100644 --- a/src/NRedisStack/Search/DataTypes/InfoResult.cs +++ b/src/NRedisStack/Search/DataTypes/InfoResult.cs @@ -5,9 +5,10 @@ namespace NRedisStack.Search.DataTypes; public class InfoResult { private readonly Dictionary _all = new(); + private static readonly string[] booleanAttributes = { "SORTABLE", "UNF", "NOSTEM", "NOINDEX", "CASESENSITIVE", "WITHSUFFIXTRIE" }; public string IndexName => GetString("index_name")!; public Dictionary IndexOption => GetRedisResultDictionary("index_options")!; - public RedisResult[][] Attributes => GetRedisResultArrayArray("attributes")!; + public Dictionary[] Attributes => GetRedisResultDictionaryArray("attributes")!; public long NumDocs => GetLong("num_docs"); public string MaxDocId => GetString("max_doc_id")!; public long NumTerms => GetLong("num_terms"); @@ -93,9 +94,28 @@ private double GetDouble(string key) return result; } - private RedisResult[][]? GetRedisResultArrayArray(string key) + private Dictionary[]? GetRedisResultDictionaryArray(string key) { if (!_all.TryGetValue(key, out var value)) return default; - return value.ToArrayArray(); + var values = (RedisResult[])value!; + var result = new Dictionary[values.Length]; + for (int i = 0; i < values.Length; i++) + { + var fv = (RedisResult[])values[i]!; + var dict = new Dictionary(); + for (int j = 0; j < fv.Length; j += 2) + { + if (booleanAttributes.Contains((string)fv[j]!)) + { + dict.Add((string)fv[j]!, fv[j--]); + } + else + { + dict.Add((string)fv[j]!, fv[j + 1]); + } + } + result[i] = dict; + } + return result; } } \ No newline at end of file diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index 5161af7f..901ef5bb 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -702,7 +702,7 @@ public void AlterAdd() IDatabase db = redisFixture.Redis.GetDatabase(); db.Execute("FLUSHALL"); var ft = db.FT(); - Schema sc = new Schema().AddTextField("title", 1.0); + Schema sc = new Schema().AddTextField("title", 1.0, sortable: true, unf: true); Assert.True(ft.Create(index, FTCreateParams.CreateParams(), sc)); @@ -733,9 +733,11 @@ public void AlterAdd() Assert.Equal(index, info.IndexName); Assert.Empty(info.IndexOption); // Assert.Equal(,info.IndexDefinition); - Assert.Equal("title", info.Attributes[0][1].ToString()); - Assert.Equal("TAG", info.Attributes[1][5].ToString()); - Assert.Equal("name", info.Attributes[2][3].ToString()); + Assert.Equal("title", info.Attributes[0]["identifier"].ToString()); + Assert.Equal("UNF", info.Attributes[0]["UNF"].ToString()); + Assert.Equal("TAG", info.Attributes[1]["type"].ToString()); + Assert.Equal("name", info.Attributes[2]["attribute"].ToString()); + Assert.Equal(100, info.NumDocs); Assert.NotNull(info.MaxDocId); Assert.Equal(102, info.NumTerms); @@ -795,9 +797,9 @@ public async Task AlterAddAsync() var info = await ft.InfoAsync(index); Assert.Equal(index, info.IndexName); - Assert.Equal("title", info.Attributes[0][1].ToString()); - Assert.Equal("TAG", info.Attributes[1][5].ToString()); - Assert.Equal("name", info.Attributes[2][3].ToString()); + Assert.Equal("title", info.Attributes[0]["identifier"].ToString()); + Assert.Equal("TAG", info.Attributes[1]["type"].ToString()); + Assert.Equal("name", info.Attributes[2]["attribute"].ToString()); Assert.Equal(100, info.NumDocs); Assert.Equal("300", info.MaxDocId); Assert.Equal(102, info.NumTerms); @@ -859,9 +861,9 @@ public void AlterAddSortable() Assert.Equal(index, info.IndexName); Assert.Empty(info.IndexOption); // Assert.Equal(,info.IndexDefinition); - Assert.Equal("title", info.Attributes[0][1].ToString()); - Assert.Equal("TAG", info.Attributes[1][5].ToString()); - Assert.Equal("name", info.Attributes[2][3].ToString()); + Assert.Equal("title", info.Attributes[0]["identifier"].ToString()); + Assert.Equal("TAG", info.Attributes[1]["type"].ToString()); + Assert.Equal("name", info.Attributes[2]["attribute"].ToString()); Assert.Equal(100, info.NumDocs); Assert.NotNull(info.MaxDocId); Assert.Equal(102, info.NumTerms); @@ -921,9 +923,9 @@ public async Task AlterAddSortableAsync() var info = await ft.InfoAsync(index); Assert.Equal(index, info.IndexName); - Assert.Equal("title", info.Attributes[0][1].ToString()); - Assert.Equal("TAG", info.Attributes[1][5].ToString()); - Assert.Equal("name", info.Attributes[2][3].ToString()); + Assert.Equal("title", info.Attributes[0]["identifier"].ToString()); + Assert.Equal("TAG", info.Attributes[1]["type"].ToString()); + Assert.Equal("name", info.Attributes[2]["attribute"].ToString()); Assert.Equal(100, info.NumDocs); Assert.Equal("300", info.MaxDocId); Assert.Equal(102, info.NumTerms); From eac720c785f665dfd8ca7522fc673fb8f84885ab Mon Sep 17 00:00:00 2001 From: atakavci Date: Fri, 14 Jun 2024 16:10:23 +0300 Subject: [PATCH 8/9] remove sortable attribute --- tests/NRedisStack.Tests/Search/SearchTests.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index 901ef5bb..8f3e5792 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -702,7 +702,7 @@ public void AlterAdd() IDatabase db = redisFixture.Redis.GetDatabase(); db.Execute("FLUSHALL"); var ft = db.FT(); - Schema sc = new Schema().AddTextField("title", 1.0, sortable: true, unf: true); + Schema sc = new Schema().AddTextField("title", 1.0); Assert.True(ft.Create(index, FTCreateParams.CreateParams(), sc)); @@ -734,7 +734,6 @@ public void AlterAdd() Assert.Empty(info.IndexOption); // Assert.Equal(,info.IndexDefinition); Assert.Equal("title", info.Attributes[0]["identifier"].ToString()); - Assert.Equal("UNF", info.Attributes[0]["UNF"].ToString()); Assert.Equal("TAG", info.Attributes[1]["type"].ToString()); Assert.Equal("name", info.Attributes[2]["attribute"].ToString()); From 3ff21d731e9ade70eb37579bd962834cd06c1b9d Mon Sep 17 00:00:00 2001 From: atakavci Date: Fri, 14 Jun 2024 17:09:33 +0300 Subject: [PATCH 9/9] remove sortable --- tests/NRedisStack.Tests/Search/SearchTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index fe8f6242..37df842e 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -702,7 +702,7 @@ public void AlterAdd() IDatabase db = redisFixture.Redis.GetDatabase(); db.Execute("FLUSHALL"); var ft = db.FT(); - Schema sc = new Schema().AddTextField("title", 1.0, sortable: true, unf: true); + Schema sc = new Schema().AddTextField("title", 1.0); Assert.True(ft.Create(index, FTCreateParams.CreateParams(), sc));