diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index 1984cb6b..6182849f 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -652,9 +652,6 @@ public void CreateWithFieldNames(string endpointId) SearchResult noFilters = ft.Search(index, new Query()); Assert.Equal(5, noFilters.TotalResults); - SearchResult asOriginal = ft.Search(index, new Query("@first:Jo*")); - Assert.Equal(0, asOriginal.TotalResults); - SearchResult asAttribute = ft.Search(index, new Query("@given:Jo*")); Assert.Equal(2, asAttribute.TotalResults); @@ -662,6 +659,19 @@ public void CreateWithFieldNames(string endpointId) Assert.Equal(1, nonAttribute.TotalResults); } + [SkipIfRedis(Comparison.LessThan, "7.9.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void FailWhenAttributeNotExist(string endpointId) + { + IDatabase db = GetCleanDatabase(endpointId); + var ft = db.FT(); + Schema sc = new Schema().AddField(new TextField(FieldName.Of("first").As("given"))) + .AddField(new TextField(FieldName.Of("last"))); + + Assert.True(ft.Create(index, FTCreateParams.CreateParams().Prefix("student:", "pupil:"), sc)); + RedisServerException exc = Assert.Throws(() => ft.Search(index, new Query("@first:Jo*"))); + } + [SkippableTheory] [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] public async Task CreateWithFieldNamesAsync(string endpointId) @@ -684,9 +694,6 @@ public async Task CreateWithFieldNamesAsync(string endpointId) SearchResult noFilters = await ft.SearchAsync(index, new Query()); Assert.Equal(5, noFilters.TotalResults); - SearchResult asOriginal = await ft.SearchAsync(index, new Query("@first:Jo*")); - Assert.Equal(0, asOriginal.TotalResults); - SearchResult asAttribute = await ft.SearchAsync(index, new Query("@given:Jo*")); Assert.Equal(2, asAttribute.TotalResults); @@ -694,6 +701,19 @@ public async Task CreateWithFieldNamesAsync(string endpointId) Assert.Equal(1, nonAttribute.TotalResults); } + [SkipIfRedis(Comparison.LessThan, "7.9.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task FailWhenAttributeNotExistAsync(string endpointId) + { + IDatabase db = GetCleanDatabase(endpointId); + var ft = db.FT(); + Schema sc = new Schema().AddField(new TextField(FieldName.Of("first").As("given"))) + .AddField(new TextField(FieldName.Of("last"))); + + Assert.True(await ft.CreateAsync(index, FTCreateParams.CreateParams().Prefix("student:", "pupil:"), sc)); + RedisServerException exc = await Assert.ThrowsAsync(async () => await ft.SearchAsync(index, new Query("@first:Jo*"))); + } + [SkipIfRedis(Is.Enterprise)] [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] public void AlterAdd(string endpointId)