-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add equals operator to Atlas Search #1606
base: main
Are you sure you want to change the base?
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.
Just a couple of comments - possibly no changes needed.
driver-core/src/main/com/mongodb/client/model/search/SearchOperator.java
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/search/SearchOperator.java
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/search/SearchOperator.java
Show resolved
Hide resolved
} | ||
|
||
/** | ||
* Returns a {@link SearchOperator} that checks whether a field matches a value you specify. |
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 docs from our docs page are confusing. I think we should say, ...that searches for documents where a field matches the specified value.
in all of these
* @return The requested {@link SearchOperator}. | ||
* @mongodb.atlas.manual atlas-search/equals/ equals operator | ||
*/ | ||
static EqualsSearchOperator equalsNull(final FieldSearchPath path) { |
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.
Based on experience, MongoDB official documentation is not always exhaustive or correct. So sometimes, when I suspect that it may be missing something, or that it may not reflect the reality, I check the actual server behavior.
Could we please check whether the equals
search operator matches not only the BSON null values, but also unset fields? That is, does the operator
{
"equals": {
"path": "job_title",
"value": null
}
}
match, for example, the empty document {}
, which does not have the field job_title
set (or, in other words, does not contain the job_title
key). The best way to check this seem to be by introducing an integration test to the PR, as then we will review the code that checks the behavior, and have the answer to the question with us for as long as we have the integration test.
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.
If we discover that documents with the field being not set match, then we should rename the equalsNull
method into something like equalsNullOrNotSet
. I don't have a preference between "not set", "unset", "missing", "absent" (we may want to see if any of these or other words are already used in the Java driver API for expressing the same), but let's not use "undefined" to avoid confusion, as there is a single-value BSON Undefined type.
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.
If we need to rename it, probably equalsNullOrNotExists (because of the $exists operator)
Ticket
JAVA-5729
Description
There are several Atlas Search query operators that are not implemented with first class support in the Java driver. This PR adds the
equals
operator to Atlas Search.Testing
./gradlew check
atlas-search-test
on EvergreenSearchOperatorTest