Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-671

Geospatial Query with implied and returns wrong results

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: API
    • Labels:
      None
    • Environment:
      OS X Mountain Lion

      the index is set with :
      db.offerings.ensureIndex(

      { coord : "2d", categoryId: 1 }

      )

      while the shell query returns 1 document :

      db.offerings.find( { coord :

      { $near : [-122,37] }

      , categoryId : '212' } );

      the java version returns two including one with categoryId not equal 212 (212 shows in the debugger as the value of cat)

      String lat = (String) this.getRequest().getAttributes().get("lat");
      String lon = (String) this.getRequest().getAttributes().get("long");
      String cat = (String) this.getRequest().getAttributes().get("cat");

      DBCollection coll = database.getCollection("offerings");
      Double locationLongitude = null;
      Double locationLatitude = null;

      try

      { locationLongitude = Double.valueOf(lon.trim()).doubleValue(); locationLatitude = Double.valueOf(lat.trim()).doubleValue(); }

      catch (NumberFormatException e)

      { System.out.println("NumberFormatException: " + e.getMessage()); }

      DBCursor cur = coll.find(new BasicDBObject("coord",JSON.parse("{$near : [ " + locationLongitude + "," + locationLatitude + " ]}, categoryId : " + cat)));

      try {
      JSONObject offeringAsJson = new JSONObject();
      while(cur.hasNext()) {
      DBObject obj = cur.next();
      System.out.println("\nGetNext value for categoryId:"+ obj.get("categoryId"));

            Assignee:
            Unassigned Unassigned
            Reporter:
            bruce_ellacott@hotmail.com Bruce Ellacott
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: