[JAVA-3338] $geoWithin cannot contain multiple fields Created: 26/Jun/19  Updated: 28/Oct/23  Resolved: 15/Dec/19

Status: Closed
Project: Java Driver
Component/s: Builders, Query Operations
Affects Version/s: 3.10.2
Fix Version/s: 4.0.0

Type: Bug Priority: Major - P3
Reporter: Mateusz Starzec Assignee: John Stewart (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to COMPASS-4475 Aggregation tool generating Java code... Closed
is related to JAVA-4006 Filters can produce invalid query sha... Closed
Backwards Compatibility: Minor Change

 Description   

As discussed in DOCS-12834, a query with the $geoWithin operator cannot contain $not next to it.

The following example is invalid:

{"coordinates": {"$geoWithin": {"$centerSphere": [[22.0, 52.0], 0.04]}, "$not": {"$geoWithin": {"$centerSphere": [[22.0, 52.0], 0.01]}}}}

Unfortunately the implementation of `AndFilter` optimizes the following snippet to the query above:

Filters.and(
  Filters.geoWithinCenterSphere("coordinates", 22, 52, 0.04),
  Filters.not(
    Filters.geoWithinCenterSphere("coordinates", 22, 52, 0.01),
  )
)



 Comments   
Comment by Githook User [ 15/Jan/20 ]

Author:

{'name': 'Ross Lawley', 'username': 'rozza', 'email': 'ross.lawley@gmail.com'}

Message: Update Scala tests for the $and Filter changes

JAVA-3338
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/7decb14e9c21b75574edb6fc2ef617204ec38573

Comment by Githook User [ 15/Jan/20 ]

Author:

{'name': 'John Stewart', 'username': 'jstewart-mongo', 'email': 'john.stewart@mongodb.com'}

Message: Simplify AndFilter to always use $and

JAVA-3338
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/b4afe55df5fd368a8e381915ceba2deeabd95fa3

Generated at Thu Feb 08 08:59:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.