-
Notifications
You must be signed in to change notification settings - Fork 49
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
GH-281 TermQuery with a string.Empty value needs .Verbatim() or it is ignored as "conditionless" #283
Conversation
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.
The fix looks good, only thing missing is we'll need an entry added into the CHANGELOG.md under a ### Fixed
header in the ## Unreleased
section.
I think there might also be value in adding a reproduce test similar to the one you shared here: #281 (comment)
@davidalpert It does appear unfortunately this fix breaks some test cases that expect empty string to be conditionless. I'm aware of your issue #282, there's unfortunately some flaky tests in general that make running the tests locally frustrating. The reproduce command from below (
|
Thank you for your response; running this command on main:
did give me a baseline green from which to test my change
and based on that I will try adding some unit tests for my change in the style of this project, and also look to include updates for any tests which break as a result of this PR 👍 |
2caf7a2
to
75707a1
Compare
@Xtansia I appreciate your prompt engagement with my issue and pull request. I have now learned that a I have updated this PR to revert my proposed change and simply add some unit tests documenting my investigation and discovery from GH-281. Feel free to merge or close without merging these additional test cases. |
75707a1
to
859b22f
Compare
…y string serializes as <null> Signed-off-by: David Alpert <[email protected]>
Further investigation shows that a TermQuery with an empty string value is expected to be 'conditionless' in this codebase and the TermQuery implementation includes a .Verbatim() method to allow the client to serialize the query clause even though it evaluates to conditionless this allows me to create a query like this GET /index/_search { "query": { "bool": { "must": [ {"exists": { "field": "last_name"}} ], "must_not": [ {"term": {"last_name.keyword": {"value": ""}}} ] } } } using the following syntax client.Search<SampleDomainObject>(s => s .Query(q => q .Bool(b => b .Must(m => m.Exists(e => e.Field("last_name"))) .MustNot(m => m.Term(t => t.Verbatim().Field("last_name.keyword").Value(string.Empty))) ) ) .Index("index") .Source(sfd => null) ); thus resolving that opensearch-projectGH-281 is not a bug and is working as designed. Signed-off-by: David Alpert <[email protected]>
opensearch-projectGH-281 Signed-off-by: David Alpert <[email protected]>
42db7ec
to
64d94a2
Compare
I have updated the PR description and added some examples to USAGE.md |
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.
Thanks for adding to the USER_GUIDE, just had a comment on the example used
opensearch-projectGH-281 Signed-off-by: David Alpert <[email protected]>
64d94a2
to
c9a9e4e
Compare
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.
Looks good, Thank you @davidalpert
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.
Does it work if a text
field has non-keyword
field? Or multiple fields?
@Yury-Fridlyand so far as I know the I am currently using this |
I see. Thank you for the details! |
Description
USAGE.md
to demonstrate use ofIsVerbatim
/Verbatim()
to includeTermQuery
s with non-null empty string valuesIssues Resolved
Resolves GH-281
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.
Signed-off-by: David Alpert [email protected]