-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Verbatim and strict query fixes #2021
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
Conversation
bool IQuery.IsWritable { get; } | ||
public bool IsVerbatim { get; set; } | ||
public bool IsStrict { get; set; } | ||
public bool IsWritable { get { return this.IsVerbatim || IsConditionless(this); } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this also be
public bool IsWritable { get { return this.IsVerbatim || !IsConditionless(this); } }
i.e. negate IsConditionless
?
I've added some tests for this. Also fixed |
I would have expected this to pass i.e. public class BoolVerbatimQueryUsageTests : QueryDslUsageTestsBase
{
protected override bool SupportsDeserialization => false;
public BoolVerbatimQueryUsageTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { }
protected override object QueryJson => new
{
@bool = new
{
must = new object[]
{
new
{
term = new
{
description = new
{
value = ""
}
}
},
new
{
term = new
{
name = new
{
value = "foo"
}
}
}
}
}
};
protected override QueryContainer QueryInitializer =>
new BoolQuery
{
// cascade to clauses?
IsVerbatim = true,
Must = new List<QueryContainer>
{
new TermQuery
{
Field = "description",
Value = ""
},
new TermQuery
{
Field = "name",
Value = "foo"
}
}
};
protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project> q) => q
.Bool(b => b
// cascade to clauses?
.Verbatim()
.Must(qt => qt
.Term(t => t
.Field(p => p.Description)
.Value("")
), qt => qt
.Term(t => t
.Field(p => p.Name)
.Value("foo")
)
)
);
} Is my thinking incorrect here? |
@@ -42,7 +42,7 @@ public class SpanQuery : ISpanQuery | |||
bool IQuery.IsWritable { get; } | |||
public bool IsVerbatim { get; set; } | |||
public bool IsStrict { get; set; } | |||
public bool IsWritable { get { return this.IsVerbatim || IsConditionless(this); } } | |||
public bool IsWritable => this.IsVerbatim || !IsConditionless(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch 👍
That's correct. IsVerbatim/Strict has to now be set at each desired query to obtain this behavior, which wasn't possible before.
That would be ideal, but not sure if it's possible for the same reason we can't cascade from QueryContainer. I could be wrong though... |
OK, apologies if we've discussed this before 😄 That does feel a little bit unintuitive for compound queries like |
5625a46
to
0bee7a5
Compare
- moved tests into their own namespace so they can be easily ran as a single unit - Rebased against 2.x and removed newly introduces InvokeQuery()'s - Renamed fluent Assign of the QueryCotainerDescriptor to WrapInContainer, since thats what it is doing and to mimic the OIS equivalent.
Rebased against 2.x appended some small touch ups, please review @gmarz LGTM 👍 |
2804af1
to
7c5cd19
Compare
the query level for the fluent syntax. Setting at the container level
for both APIs is a noop.
never thrown.
Closes #1898
Closes #1876