[JAVA-3572] The Filters.geoIntersects returns nothing from Java App while querying for the same data from Robo 3T returns some Created: 27/Dec/19  Updated: 27/Dec/19  Resolved: 27/Dec/19

Status: Closed
Project: Java Driver
Component/s: Builders
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: John Dang Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I have a Java app using MongoDb ( client version 3.12). I have a Java app using MongoDb ( client version 3.12). The Filters.geoIntersects returns nothing from Java App while querying for the same data from Robo 3T returns some and here is code for both Java and script. What's wrong with my Java code. Am I missing something?

``` javascript
// Using script in Robo 3T ==> returns a few records

db.getCollection('locations').find( {
place: {
$geoIntersects: {
$geometry:

{ type: "Point" , coordinates: [131.005440, 33.784371 ] }

}
}
}
)

// Java code returns nothing 

collection = db.getCollection("locations"); 

Point curPos = new Point(new Position(131.005440, 33.784371));  collection.find(Filters.geoIntersects("place.coordinates", curPos))    .forEach(new Consumer<Document>() {    @Override    public void accept(Document t)

{ logger.info( t.toJson());       }

    });

```



 Comments   
Comment by John Dang [ 27/Dec/19 ]

That's,  I thought the coordinates have to be a part of the field. Please close this item.

Comment by Jeffrey Yemin [ 27/Dec/19 ]

The Java filter generates the following query:

{
  "place.coordinates": {
    "$geoIntersects": {
      "$geometry": {
        "type": "Point",
        "coordinates": [
          131.00544,
          33.784371
        ]
      }
    }
  }
}

The difference appears to be the field name. Filters.geoIntersects("place", curPos) generates the identical query as Robo 3T.

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