diff --git a/.github/workflows/nuget-release.yml b/.github/workflows/nuget-release.yml
index 5a9b5d23..3a0c3e09 100644
--- a/.github/workflows/nuget-release.yml
+++ b/.github/workflows/nuget-release.yml
@@ -19,6 +19,25 @@ jobs:
run: dotnet --list-sdks
- name: Check .NET runtimes
run: dotnet --list-runtimes
+
+ - name: get version from tag
+ id: get_version
+ run: |
+ realversion="${GITHUB_REF/refs\/tags\//}"
+ realversion="${realversion//v/}"
+ echo "VERSION=$realversion" >> $GITHUB_OUTPUT
+
+ - name: Update version in csproj
+ run: |
+ VERSION=${{ steps.get_version.outputs.VERSION }}
+ echo "Setting version to $VERSION"
+
+ # Update the version in the NRedisStack.csproj file
+ sed -i "s|.*|$VERSION|" ./src/NRedisStack/NRedisStack.csproj
+ sed -i "s|.*|$VERSION|" ./src/NRedisStack/NRedisStack.csproj
+ sed -i "s|.*|$VERSION|" ./src/NRedisStack/NRedisStack.csproj
+ cat ./src/NRedisStack/NRedisStack.csproj
+
- name: Build
run: dotnet pack -c Release --output .
- name: Publish
diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml
index 755153b1..5f41716b 100644
--- a/.github/workflows/reusable.yml
+++ b/.github/workflows/reusable.yml
@@ -37,7 +37,10 @@ jobs:
- name: .NET Core 8
uses: actions/setup-dotnet@v3
with:
- dotnet-version: 8
+ dotnet-version: |
+ 6
+ 7
+ 8
- name: Run redis-stack-server docker
working-directory: .github
diff --git a/src/NRedisStack/Pipeline.cs b/src/NRedisStack/Pipeline.cs
index 67f23ff8..3035576b 100644
--- a/src/NRedisStack/Pipeline.cs
+++ b/src/NRedisStack/Pipeline.cs
@@ -6,6 +6,7 @@ public class Pipeline
{
public Pipeline(IDatabase db)
{
+ db.SetInfoInPipeline();
_batch = db.CreateBatch();
}
diff --git a/src/NRedisStack/Search/DataTypes/InfoResult.cs b/src/NRedisStack/Search/DataTypes/InfoResult.cs
index b676ca24..f931df92 100644
--- a/src/NRedisStack/Search/DataTypes/InfoResult.cs
+++ b/src/NRedisStack/Search/DataTypes/InfoResult.cs
@@ -1,14 +1,20 @@
-using StackExchange.Redis;
+using System.Reflection.Emit;
+using StackExchange.Redis;
namespace NRedisStack.Search.DataTypes;
public class InfoResult
{
private readonly Dictionary _all = new();
- private static readonly string[] booleanAttributes = { "SORTABLE", "UNF", "NOSTEM", "NOINDEX", "CASESENSITIVE", "WITHSUFFIXTRIE" };
+ private Dictionary[] _attributes;
+ private Dictionary _indexOption;
+ private Dictionary _gcStats;
+ private Dictionary _cursorStats;
+
+ private static readonly string[] booleanAttributes = { "SORTABLE", "UNF", "NOSTEM", "NOINDEX", "CASESENSITIVE", "WITHSUFFIXTRIE", "INDEXEMPTY", "INDEXMISSING" };
public string IndexName => GetString("index_name")!;
- public Dictionary IndexOption => GetRedisResultDictionary("index_options")!;
- public Dictionary[] Attributes => GetRedisResultDictionaryArray("attributes")!;
+ public Dictionary IndexOption => _indexOption = _indexOption ?? GetRedisResultDictionary("index_options")!;
+ public Dictionary[] Attributes => _attributes = _attributes ?? GetAttributesAsDictionaryArray()!;
public long NumDocs => GetLong("num_docs");
public string MaxDocId => GetString("max_doc_id")!;
public long NumTerms => GetLong("num_terms");
@@ -48,9 +54,9 @@ public class InfoResult
public long NumberOfUses => GetLong("number_of_uses");
- public Dictionary GcStats => GetRedisResultDictionary("gc_stats")!;
+ public Dictionary GcStats => _gcStats = _gcStats ?? GetRedisResultDictionary("gc_stats")!;
- public Dictionary CursorStats => GetRedisResultDictionary("cursor_stats")!;
+ public Dictionary CursorStats => _cursorStats = _cursorStats ?? GetRedisResultDictionary("cursor_stats")!;
public InfoResult(RedisResult result)
{
@@ -94,24 +100,29 @@ private double GetDouble(string key)
return result;
}
- private Dictionary[]? GetRedisResultDictionaryArray(string key)
+ private Dictionary[]? GetAttributesAsDictionaryArray()
{
- if (!_all.TryGetValue(key, out var value)) return default;
+ if (!_all.TryGetValue("attributes", 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)
+
+ IEnumerable enumerable = (RedisResult[])values[i]!;
+ IEnumerator results = enumerable.GetEnumerator();
+ while (results.MoveNext())
{
- if (booleanAttributes.Contains((string)fv[j]!))
+ string attribute = (string)results.Current;
+ // if its boolean attributes add itself to the dictionary and continue
+ if (booleanAttributes.Contains(attribute))
{
- dict.Add((string)fv[j]!, fv[j--]);
+ dict.Add(attribute, results.Current);
}
else
- {
- dict.Add((string)fv[j]!, fv[j + 1]);
+ {//if its not a boolean attribute, add the next item as value to the dictionary
+ results.MoveNext(); ;
+ dict.Add(attribute, results.Current);
}
}
result[i] = dict;
diff --git a/src/NRedisStack/Search/Document.cs b/src/NRedisStack/Search/Document.cs
index 3223054f..c8f9dec5 100644
--- a/src/NRedisStack/Search/Document.cs
+++ b/src/NRedisStack/Search/Document.cs
@@ -31,6 +31,10 @@ public static Document Load(string id, double score, byte[]? payload, RedisValue
{
Document ret = new Document(id, score, payload);
if (fields == null) return ret;
+ if (fields.Length == 1 && fields[0].IsNull)
+ {
+ return ret;
+ }
for (int i = 0; i < fields.Length; i += 2)
{
string fieldName = fields[i]!;
diff --git a/src/NRedisStack/Search/FieldName.cs b/src/NRedisStack/Search/FieldName.cs
index b07d23f4..eee3ca7e 100644
--- a/src/NRedisStack/Search/FieldName.cs
+++ b/src/NRedisStack/Search/FieldName.cs
@@ -2,27 +2,27 @@ namespace NRedisStack.Search
{
public class FieldName
{
- private readonly string fieldName;
- private string? alias;
+ public string Name { get; }
+ public string? Alias { get; private set; }
public FieldName(string name) : this(name, null) { }
public FieldName(string name, string? attribute)
{
- this.fieldName = name;
- this.alias = attribute;
+ this.Name = name;
+ this.Alias = attribute;
}
public int AddCommandArguments(List