Skip to content
Merged
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
42 changes: 38 additions & 4 deletions tests/NRedisStack.Tests/Search/SearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,40 @@ private async Task AssertIndexSizeAsync(ISearchCommandsAsync ft, string index, i
Assert.Equal(expected, indexed);
}

[Theory]
[MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))]
public void TestSearchLimitOffset(string endpointId)
{
SkipClusterPre8(endpointId);

// Cluster + RESP3 ignores the LIMIT offset server-side: FT.SEARCH returns the window
// [0, offset+count) instead of [offset, offset+count). This is a RediSearch module bug,
// not a client bug (the raw wire reply already contains the wrong documents); skip until fixed.
// https://github.com/RediSearch/RediSearch/issues/10369
Assert.SkipWhen(endpointId == EndpointsFixture.Env.Cluster && TestContext.Current.GetRunProtocol().IsResp3(),
"RediSearch#10369: FT.SEARCH on cluster+RESP3 ignores the LIMIT offset");

IDatabase db = GetCleanDatabase(endpointId);
var ft = db.FT();
Schema sc = new();
sc.AddNumericField("count", sortable: true);
ft.Create(index, FTCreateParams.CreateParams(), sc);

const int total = 30;
for (int i = 0; i < total; i++)
{
AddDocument(db, new Document($"data{i:D2}").Set("count", i));
}

AssertIndexSize(ft, index, total);

var query = new Query("*").SetNoContent(false).SetSortBy("count", ascending: true).Limit(20, 10);
var results = ft.Search(index, query);

Assert.Equal(total, results.TotalResults);
Assert.Equal(10, results.Documents.Count);
Comment thread
mgravell marked this conversation as resolved.
}

[SkipIfRedisTheory(Is.Enterprise)]
[MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))]
public void TestAggregationRequestVerbatim(string endpointId)
Expand Down Expand Up @@ -891,7 +925,7 @@ public void AlterAdd(string endpointId)
Assert.Equal(102, info.NumTerms);
Assert.True(info.NumRecords >= 200);
Assert.True(info.InvertedSzMebibytes < 1); // TODO: check this line and all the <1 lines
log.WriteLine($"{nameof(info.VectorIndexSzMebibytes)}: {info.VectorIndexSzMebibytes}"); // version-dependent
Log($"{nameof(info.VectorIndexSzMebibytes)}: {info.VectorIndexSzMebibytes}"); // version-dependent
Assert.Equal(208, info.TotalInvertedIndexBlocks);
Assert.True(info.OffsetVectorsSzMebibytes < 1);
Assert.True(info.DocTableSizeMebibytes < 1);
Expand Down Expand Up @@ -979,7 +1013,7 @@ public async Task AlterAddAsync(string endpointId)
Assert.Equal(102, info.NumTerms);
Assert.True(info.NumRecords >= 200);
Assert.True(info.InvertedSzMebibytes < 1); // TODO: check this line and all the <1 lines
log.WriteLine($"{nameof(info.VectorIndexSzMebibytes)}: {info.VectorIndexSzMebibytes}"); // version-dependent
Log($"{nameof(info.VectorIndexSzMebibytes)}: {info.VectorIndexSzMebibytes}"); // version-dependent
Assert.Equal(208, info.TotalInvertedIndexBlocks);
Assert.True(info.OffsetVectorsSzMebibytes < 1);
Assert.True(info.DocTableSizeMebibytes < 1);
Expand Down Expand Up @@ -1057,7 +1091,7 @@ public void AlterAddSortable(string endpointId)
Assert.Equal(102, info.NumTerms);
Assert.True(info.NumRecords >= 200);
Assert.True(info.InvertedSzMebibytes < 1); // TODO: check this line and all the <1 lines
log.WriteLine($"{nameof(info.VectorIndexSzMebibytes)}: {info.VectorIndexSzMebibytes}"); // version-dependent
Log($"{nameof(info.VectorIndexSzMebibytes)}: {info.VectorIndexSzMebibytes}"); // version-dependent
Assert.Equal(208, info.TotalInvertedIndexBlocks);
Assert.True(info.OffsetVectorsSzMebibytes < 1);
Assert.True(info.DocTableSizeMebibytes < 1);
Expand Down Expand Up @@ -1169,7 +1203,7 @@ public async Task AlterAddSortableAsync(string endpointId)
Assert.Equal(102, info.NumTerms);
Assert.True(info.NumRecords >= 200);
Assert.True(info.InvertedSzMebibytes < 1); // TODO: check this line and all the <1 lines
log.WriteLine($"{nameof(info.VectorIndexSzMebibytes)}: {info.VectorIndexSzMebibytes}"); // version-dependent
Log($"{nameof(info.VectorIndexSzMebibytes)}: {info.VectorIndexSzMebibytes}"); // version-dependent
Assert.Equal(208, info.TotalInvertedIndexBlocks);
Assert.True(info.OffsetVectorsSzMebibytes < 1);
Assert.True(info.DocTableSizeMebibytes < 1);
Expand Down
Loading