Using a Geo Scalar Value Variabe in a Geo "near" function doesn't work

Here user.location is indexed “geo”

{
 var(func(uid(0x1))){
location as user.location
}
  matches(func:near(user.location,location,100000)){
    user.userName
  }
}

Tried storing longitude and latitude as seperate values and then using them in the function, doesn’t work too:

{
   var(func(uid(0x1))){
longitude as math(user.longitude)
latitude as math(user.latitude)
}

  matches(func:near(user.location,[longitude,latitude],100000)) {
  userId:uid
  longitude:user.longitude
  latitude:user.latitude
  }
}

Is there any way to avoid passing longitude and latitude values directly:

{

  matches(func:near(user.location,[7,9.0765],100000)) {
	userId:uid
  longitude:user.longitude
  latitude:user.latitude
  }
}
1 Like

The correct syntax would be [val(longitude),val(latitude)], but as far I know geo func doesn’t supports this.

So I have to first grab the users location on the client then send another query using that location.

Could this be added as a feature request ?

Could, but I can’t see this being supported in short or medium term.

Technical challenges ?. I could contribute if possible.

It’s a matter of demand, the team is focused on more punctual things. Features like Geo is rarely used, so you can even request an enhancement. But it will take a while until the priority of it changes.

But PRs are welcome tho.

Okay, thanks will look over the repo once I can

Hey good people. Is there any update on this? The current work around is doing a first query, getting the lat/lng in the application and the going back to the database to do the near query with the lat/lng array extracted from the geo field.

This would save a lot of round trips (depends on your dataset of course). Here we are talking about 300k+ points that will need to go through this process.

2 Likes

Just open an issue with a detailed context of how usefult it would be. Paste the link here and anywhere it has relation. Let’s say, you see a comment that fits this feature. So you ask that person to support your issue.

That way we know how useful this is for the community and the team will have a param to determine the priority.

Cheers.