diff --git a/tests/Tests.Reproduce/GitHubIssue281.cs b/tests/Tests.Reproduce/GitHubIssue281.cs index 97b59c5754..18445eb10c 100644 --- a/tests/Tests.Reproduce/GitHubIssue281.cs +++ b/tests/Tests.Reproduce/GitHubIssue281.cs @@ -50,7 +50,7 @@ public class SampleDomainObject } [U] - public void GithubIssu281_MustNotWithTermQueryAndEmptyValueShouldBeInRequestBody() + public void GithubIssu281_MustNotWithTermQueryAndVerbatimEmptyValueShouldBeInRequestBody() { var connectionSettings = new ConnectionSettings(new InMemoryConnection()).DisableDirectStreaming(); var client = new OpenSearchClient(connectionSettings); @@ -60,7 +60,7 @@ public void GithubIssu281_MustNotWithTermQueryAndEmptyValueShouldBeInRequestBody .Query(q => q .Bool(b => b .Must(m => m.Exists(e => e.Field("last_name"))) - .MustNot(m => m.Term(t => t.Field("last_name.keyword").Value(string.Empty))) + .MustNot(m => m.Term(t => t.Verbatim().Field("last_name.keyword").Value(string.Empty))) ) ) .Index("index") @@ -76,13 +76,13 @@ public void GithubIssu281_MustNotWithTermQueryAndEmptyValueShouldBeInRequestBody } [U] - public void GithubIssue281_MustNotTermQueryAndEmptyValueShouldBeRegisteredAsNonNull() + public void GithubIssue281_MustNotTermQueryAndVerbatimEmptyValueShouldBeRegisteredAsNonNull() { Func, ISearchRequest> selector = s => s .Query(q => q .Bool(b => b .Must(m => m.Exists(e => e.Field("last_name"))) - .MustNot(m => m.Term(t => t.Field("last_name.keyword").Value(string.Empty))) + .MustNot(m => m.Term(t => t.Verbatim().Field("last_name.keyword").Value(string.Empty))) ) ) .Index("index") @@ -97,18 +97,18 @@ public void GithubIssue281_MustNotTermQueryAndEmptyValueShouldBeRegisteredAsNonN // this too... query.Bool.MustNot.Should().NotBeEmpty(); - // ... but this is fails as the collection contains one `` entry which explains why it's missing from the serialized request JSON + // ... and this passes so long as `.Verbatim()` is used in the `TermQuery` query.Bool.MustNot.First().Should().NotBeNull("MustNot"); } [U] - public void GithubIssue281_MustNotTermQueryAndNonEmptyValueShouldBeRegisteredAsNonNull() + public void GithubIssue281_MustNotTermQueryAndNonVerbatimEmptyValueShouldBeRegisteredAsNonNull() { Func, ISearchRequest> selector = s => s .Query(q => q .Bool(b => b .Must(m => m.Exists(e => e.Field("last_name"))) - .MustNot(m => m.Term(t => t.Field("last_name.keyword").Value("mal"))) + .MustNot(m => m.Term(t => t.Verbatim().Field("last_name.keyword").Value("mal"))) ) ) .Index("index") @@ -164,10 +164,10 @@ public void GithubIssue281_TermQueryWithNonEmptyValueSerializesToNonNullResult() } [U] - public void GithubIssue281_TermQueryWithEmptyValueSerializesToNonNullResult() + public void GithubIssue281_TermQueryWithVerbatimEmptyValueSerializesToNonNullResult() { Func, QueryContainer> termQuery = - m => m.Term(t => t.Field("last_name.keyword").Value(string.Empty)); + m => m.Term(t => t.Verbatim().Field("last_name.keyword").Value(string.Empty)); var result = termQuery.Invoke(new QueryContainerDescriptor()); @@ -177,7 +177,7 @@ public void GithubIssue281_TermQueryWithEmptyValueSerializesToNonNullResult() [TU] [InlineData("null", null, true)] [InlineData("non-empty string", "doe", false)] - [InlineData("empty string", "", false)] + [InlineData("empty string", "", true)] public void GithubIssue281_TermQueryIsConditionless(string scenario, string val, bool expected) { bool SimulateIsConditionless(ITermQuery q)