Near geo query sig digits issue

I’ve been using the near function and it seems to be giving me really weird responses that do not make sense. I’ve been passing in geo locations that are the exact coords of a node and the query does not give me back that node as expected. In fact this query will return

My geo data is accurate to the 7th decimal place and I’m wondering if there are limitations for the amount of significant digits considered in the query’s computation to explain this? The result is only ever really accurate to the second decimal place.

Query

{
    # Get all nodes in the target location
		N as var(func: type(Node)) @cascade {
      loc @filter(eq(name@en, "MyLocation"))
    }

    # Grab the closest nodes given the target location.
    # The coordinates provided are the same as an existing node.
    closest_node(func: near(location, [ -80.490292, 43.455985], 1000), first: 1) @filter(uid(N)) {
      uid
      location
      elevation
    }
  }

Response

{
  "data": {
    "closest_node": [
      {
        "uid": "0x186a4",
        "location": {
          "type": "Point",
          "coordinates": [
            -80.4996264,
            43.4509706
          ]
        },
        "elevation": 80
      }
    ]
  },
...
}

Will return what?

But as far as I know, Geo Data is 4 decimal places. Is it another standard?

I can’t see what you mean.

Why this filter? I think that this is unnecessary. As the near will look into the indexed values. Using the first block to get more nodes will create more things to compute. If you need to apply a filter you can apply in the near block itself.

{
    closest_node(func: near(location, [ -80.490292, 43.455985], 1000), first: 1) @cascade {
      uid
      location @filter(eq(name@en, "MyLocation"))
      elevation
    }
  }

About your issue, please provide more context. I really don’t understand it.

The “In fact this query will return” was just a statement I forgot to delete.

I’ve simplified my query as suggested using the cascade tag as suggested, but the issue still remains for myself that the returned node is incorrect in terms what is actually the closest node in the database.

The 7th decimal place accuracy is not a standard, but the level of accuracy our proprietary system operates on. If nearest only computes to the 4th decimal place that helps, but still remains the responses I’m getting from that built-in function are still incorrect regardless.

Ex.
Nearest location : [ -80.490292, 43.455985]
Expectation: [ -80.490292, 43.455985] (since a node with this exact location exists in the db)
Result: [ -80.4996264, 43.4509706 ]

The function seems to return these incorrect answers when the expected answer is very close to the queried location (have to do some empirical measurements as to how close they need to be for the issue to arise).

Looking at the documentation again I’ve determined that the issue I was having is assuming the node returned by the query would be the closest node to the given geolocation. This is in fact not the case as near just returns nodes that are within the radius.

Is there a way to order the results by distance to the provided geolocation?

Not possible as far as I know, you should use some third-party lib.