How to use equals operator for atlas search in mongodb-driver-core Java library

I am using mongodb-driver-core 4.9.0, and noticed that the library does not offer many operators, like equals as mentioned in

May I ask if I am missing anything here, or I would have to use SearchOperator.of(...) here? If so, I tried to pass in the equals Bson document, but it does not work in my query.

Looks forwards to your help! Thank you!

Yeah, it doesn’t look like there is no builder for equals. If you reply with the code you tried for using of, along with the expect and actual output, we can try to figure out what’s going wrong.

Hi Jeffrey, thank you for your reply!

I am trying to do something like:

  private static final String EQUAL_CLAUSE = """
        "equals": {
          "path": "myFlag",
          "value": true
      CompoundSearchOperator compoundSearchOperator = SearchOperator.compound().filter(filterOperators);
      if (!mustOperators.isEmpty()) {
        compoundSearchOperator = compoundSearchOperator.must(mustOperators);
      if (!shouldOperators.isEmpty()) {
        compoundSearchOperator = compoundSearchOperator.should(shouldOperators);

However, it would yield with no results for me.

It sounds like the Java driver part is working ok, but the query just doesn’t match. You might want to look in logs to confirm that the query is generated as you expect, and then check your data against the query, and re-read the docs, to see why you’re not getting results.


Found the issue in the index configuration. all good now.

Thank you!

Hey, may I ask how do you fix the issue? What is wrong with the index configuration?
I am facing the same issue

And indeed there is no builder for equals see here: SearchOperator (driver-core 4.10.0 API) (

Sorry, tbh, I cannot remember what I did…
I think maybe I initially did not configure to use lucene.standard as the Analyzer. Would you check that? Or did you turn on the dynamic mapping?

(Perhaps pasting your index mapping JSON here would be helpful to identify the cause)