spatial icon indicating copy to clipboard operation
spatial copied to clipboard

Cypher query to return nodes using spatial instead deleting nodes

Open jturmel opened this issue 11 years ago • 11 comments

Created a spatial index: "cities" Add a node with the proper fields needed to the index. Use the REST API to verify it comes back and spatial is working, this works. Run a Cypher query to get the results:

start r = node:cities("withinDistance:[35.0,-97.0,10000.0]") return r

This returns 0 rows, if I then check to see if that node still exists, it doesn't, it's been removed.

Running neo4j 2.0.1 and spatial 2.0.1

jturmel avatar May 04 '14 22:05 jturmel

Anyone else seeing this?

jturmel avatar May 14 '14 12:05 jturmel

I'm not seeing the behavior that removes the nodes, but I do agree that the cypher query does not work properly if you use the addNodesToLayer method of the plugin. In fact you can see here that it doesn't even work in the unit tests:

"//in this version not supported future feature"

I'm going to try to open up an issue to get some guidance on how to fix this and submit a pull request.

pdtyreus avatar May 24 '14 16:05 pdtyreus

Good catch.

I'm going to try by adding the node to the index in the more conventional way.

— Sent from Mailbox

On Sat, May 24, 2014 at 11:37 AM, P. Daniel Tyreus [email protected] wrote:

I'm not seeing the behavior that removes the nodes, but I do agree that the cypher query does not work properly if you use the addNodesToLayer method of the plugin. In fact you can see here that it doesn't even work in the unit tests: "//in this version not supported future feature"

I'm going to try to open up an issue to get some guidance on how to fix this and submit a pull request.

Reply to this email directly or view it on GitHub: https://github.com/neo4j/spatial/issues/137#issuecomment-44092570

jturmel avatar May 25 '14 13:05 jturmel

Sorry, yes currently only nodes that are added via the index are returned via cypher. I had a work in progress somehwere that allowed to have different index configs to also allow to return the actual geometry-nodes instead (i.e. when you don't create additional nodes in the geo-index for your domain nodes).

But currently too many other things on my plate to look into that.

jexp avatar May 26 '14 00:05 jexp

@jexp thanks for the confirmation, any thoughts on the deletion of the nodes when doing it how I described above?

jturmel avatar May 26 '14 03:05 jturmel

Hey guys. We've too have encountered this exact issue while trying to index nodes using the addNodeToLayer (and addNodesToLayer) method. Curiously, using neo's legacy indexing endpoint completely circumvents this issue, and works perfectly.

schonfeld avatar May 28 '14 23:05 schonfeld

Did you experience the deleting of the nodes issue as well?

— Sent from Mailbox

On Wed, May 28, 2014 at 6:40 PM, Michael Schonfeld [email protected] wrote:

Hey guys. We've too have encountered this exact issue while trying to index nodes using the addNodeToLayer (and addNodesToLayer) method. Curiously, using neo's legacy indexing endpoint completely circumvents this issue, and works perfectly.

Reply to this email directly or view it on GitHub: https://github.com/neo4j/spatial/issues/137#issuecomment-44478515

jturmel avatar May 29 '14 00:05 jturmel

@jturmel I did! Every time I cypher using spatial queried (START locations = node:locations('withinDistance:[...]') return locations), it would return 0 results, and proceed to delete any associated nodes.

schonfeld avatar May 29 '14 03:05 schonfeld

I think the problem stems from confusion about using the 'id' property and connecting your 'real' node that you want to the rtree instead of using an intermediary node that is going to point to the node you want.

When using the /db/data/index endpoint provided by legacy indexing from neo4j you get that 'for free' while using the /addNodeToLayer does not. The reason nodes start getting deleted is because the end user, innocently, used an "id" property for their own purposes and then connect that node to the tree. Then GeoPipeFlowHits tries to fetch the first record and inside underlyingObjectToObject doesn't find it by the so called "id" given since it takes that string and then searches the neo4j db for that literal id. Since it doesn't find it, an exception is generated which subsequently ends up making a call to itemDodged removing that node.

Ofcourse reading the top comment in GeoPipeFlowHits tells you why that was done that way, but here we have a situation where we end up inside itemDodged without really having a node that was removed from the index but not removed from the database.

@jturmel what do you think is the best way to go about this misunderstanding? I can help with pull requests as long as you tell me where you want to take it

danielschonfeld avatar May 29 '14 23:05 danielschonfeld

Okay, I see what you're saying.

Would just some better documentation suffice then? Not sure, I don't feel I know enough about the internals of spatial to give a highly valuable opinion. :)

jturmel avatar May 30 '14 01:05 jturmel

Oh sorry I meant to cc @jexp - my apologies @jturmel

danielschonfeld avatar May 30 '14 01:05 danielschonfeld