Skip to content

Commit

Permalink
ft.profile response change redis#312
Browse files Browse the repository at this point in the history
  • Loading branch information
atakavci committed Jun 20, 2024
1 parent 4b10eac commit 6cc818b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
24 changes: 16 additions & 8 deletions src/NRedisStack/ResponseParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -670,16 +670,24 @@ public static Dictionary<string, RedisResult> ToStringRedisResultDictionary(this
{
var res = (RedisResult[])value!;
var dict = new Dictionary<string, RedisResult>();
foreach (var pair in res)
if (res[0].Resp2Type == ResultType.SimpleString || res[0].Resp3Type == ResultType.SimpleString)
{
var arr = (RedisResult[])pair!;
if (arr.Length > 1)
{
dict.Add(arr[0].ToString()!, arr[1]);
}
else
dict.Add(res[0].ToString(), res[1]);
dict.Add(res[2].ToString(), res[3]);
}
else
{
foreach (var pair in res)
{
dict.Add(arr[0].ToString()!, null);
var arr = (RedisResult[])pair!;
if (arr.Length > 1)
{
dict.Add(arr[0].ToString()!, arr[1]);
}
else
{
dict.Add(arr[0].ToString()!, null);
}
}
}
return dict;
Expand Down
12 changes: 6 additions & 6 deletions tests/NRedisStack.Tests/Search/SearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2619,7 +2619,7 @@ public async Task getSuggestionLengthAndDeleteSuggestionAsync()
Assert.Equal(2L, await ft.SugLenAsync(key));
}

[SkipIfRedis(Is.Enterprise)]
[SkipIfRedis(Is.Enterprise, Comparison.GreaterThanOrEqual, "7.3.240")]
public void TestProfileSearch()
{
IDatabase db = redisFixture.Redis.GetDatabase();
Expand All @@ -2643,7 +2643,7 @@ public void TestProfileSearch()
Assert.Equal("1", iteratorsProfile["Size"].ToString());
}

[SkipIfRedis(Is.Enterprise)]
[SkipIfRedis(Is.Enterprise, Comparison.GreaterThanOrEqual, "7.3.240")]
public async Task TestProfileSearchAsync()
{
IDatabase db = redisFixture.Redis.GetDatabase();
Expand Down Expand Up @@ -2744,7 +2744,7 @@ public void TestProfileIssue306()
var searchRes = profileSearch.Item1;
var searchDet = profileSearch.Item2;

Assert.Equal(6, searchDet.Count);
Assert.True(searchDet["Shards"][0].Length >= 12);
Assert.Equal(2, searchRes.Documents.Count);


Expand All @@ -2753,7 +2753,7 @@ public void TestProfileIssue306()
var profileAggregate = ft.ProfileAggregate(index, aggReq);
var aggregateRes = profileAggregate.Item1;
var aggregateDet = profileAggregate.Item2;
Assert.True(aggregateDet.Count >= 6);
Assert.True(aggregateDet["Shards"][0].Length >= 12);
Assert.Equal(2, aggregateRes.TotalResults);
}

Expand All @@ -2774,15 +2774,15 @@ public async Task TestProfileAsyncIssue306()
var searchRes = profileSearch.Item1;
var searchDet = profileSearch.Item2;

Assert.Equal(6, searchDet.Count);
Assert.True(searchDet["Shards"][0].Length >= 12);
Assert.Equal(2, searchRes.Documents.Count);

// check using AggregationRequest
var aggReq = new AggregationRequest("*").Load(FieldName.Of("t")).Apply("startswith(@t, 'hel')", "prefix");
var profileAggregate = await ft.ProfileAggregateAsync(index, aggReq);
var aggregateRes = profileAggregate.Item1;
var aggregateDet = profileAggregate.Item2;
Assert.True(aggregateDet.Count >= 6);
Assert.True(aggregateDet["Shards"][0].Length >= 12);
Assert.Equal(2, aggregateRes.TotalResults);
}

Expand Down

0 comments on commit 6cc818b

Please sign in to comment.