Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort nodes by point distance from another point #3900

Open
Sapulidi opened this issue Sep 6, 2023 · 0 comments
Open

Sort nodes by point distance from another point #3900

Sapulidi opened this issue Sep 6, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@Sapulidi
Copy link

Sapulidi commented Sep 6, 2023

Bascially, I would like to be able to get the 100 (limit) people who are closest to a certain location. And if possible sort them afterwards but that can be done in post processing if needed.

I am building an application that shows me nodes who are close to my location. Let's say I have 5 nodes: A, B, C, D and E. Node A is closest to me and node E is the farthest away. I expect the following query to return A, B and C but instead it returns A, B and E.

{
  "where": {
    "location_LT": {
      "point": {
        "longitude": xxx,
        "latitude": xxx
      },
      "distance": 10000
    },
  },
  "options": {
    "limit": 3,
    "sort": [
      {
        "location": "ASC"
      }
    ]
  }
}

I just found out through the Discord server that the sort is not related to the location (which I thought it was). I currently get a fairly good results if I make 2 separate queries LT and GT but if I add more filtering, some nodes nearby that should be in the results get dropped.

An example of what I'd like might look like this (if you implement this I trust you will use better naming than me).

{
  "where": {
    "location_NEIGHBOUR": {
      "point": {
        "longitude": xxx,
        "latitude": xxx
      },
    },
  },
  "options": {
    "limit": 3,
    "sort": "NEAR" | "FAR"
  }
}

For more context (Neo4J Discord thread): https://discord.com/channels/787399249741479977/1148644450097168524

Thanks!

@Sapulidi Sapulidi added the enhancement New feature or request label Sep 6, 2023
@neo4j neo4j deleted a comment from helenesanche Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant