3
votes

After discussing retrieving paths in .NET in this question, I see why I've been having difficulties. I started running cypher queries directly against REST and found that when your query returns a path, it is returned in a RESTful manner, i.e the URIs for the nodes and relationships in question.

This has been causing me a fair amount of trouble. I need to retrieve the nodes themselves and their relationships. I know the server can do this, as running any path-style query on the server shell gets JSON objects that contain all the pathy goodness I'd be after. I don't think Neo4JClient has any way around this, since there's nothing to retrieve the path's nodes and relationships themselves through REST, at least as far as I can tell.

If it helps to have a context, I'm trying to retrieve paths from the database to display in a front end.

Is there any way of retrieving the nodes and relationships for a path in one, like can be done on the shell or in Java et al? If not, what is my best alternative? Should I try writing a plugin?

A simple sample REST request (copied from webadmin rest console) is below:

post /db/data/cypher { "query" : "start n = node:myindex(ID='1') MATCH p = n<-[:RELATED_TO]-m RETURN p;" }
1

1 Answers

1
votes

Maybe you can return just the node IDs in Cypher like so:

start n=node:node_auto_index(name='Neo') 
match p=n-[r:KNOWS*]-m 
return EXTRACT( n in nodes(p) : id(n) ) as node_ids_on_path

? See http://console.neo4j.org/r/5a02od for an example