Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ft.profile response change #312 #313

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 4 additions & 4 deletions tests/NRedisStack.Tests/Search/SearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2877,7 +2877,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 @@ -2886,7 +2886,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 @@ -2907,15 +2907,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
Loading