Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-54764

Geo predicates should not inspect neighboring elements

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
    • Query Integration

      It looks like at least $geoWithin and $geoIntersects will reject sibling predicates on the same field. This is inconsistent with other path-accepting predicates like $lt and $gt:

      > db.foo.find({x: {$geoWithin: {"$centerSphere": [[22.0, 52.0], 0.04]}, $lt: 2}})
      Error: error: {
              "ok" : 0,
              "errmsg" : "can't parse extra field: $lt: 2.0",
              "code" : 2,
              "codeName" : "BadValue"
      }
      > db.foo.find({x: {$gt: 0, $lt: 2}})
      

      For $near it looks like there is some 'legacy' form of the query which we are able to parse which needs to look at neighboring elements:

      > db.foo.createIndex({loc: "2d"})
      {
              "numIndexesBefore" : 1,
              "numIndexesAfter" : 2,
              "createdCollectionAutomatically" : false,
              "ok" : 1
      }
      > db.foo.find({loc: {$near: [0, 0], $minDistance: 1}})
      > db.foo.find({loc: {$near: [0, 0], $minDistance: 1, $gt: 2}})
      Error: error: {
              "ok" : 0,
              "errmsg" : "invalid argument in geo near query: $gt",
              "code" : 34413,
              "codeName" : "Location34413"
      }
      

      It's unclear whether we should continue to error on unrecognized fields in that context. It's a strange grammar there.

            Assignee:
            backlog-query-integration [DO NOT USE] Backlog - Query Integration
            Reporter:
            charlie.swanson@mongodb.com Charlie Swanson
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: