Background:
I am using a locally run Neo4J instance, (at localhost:7474), and accessing it through a Java adaptor which uses Cypher via the REST API (with Jersey), and makes data accessible to my Grails app running on the same server.
Question:
Is it possible to query a Neo4J db using Cypher, via the REST API, and return the URI of a node? Right now, I can check Neo4J server status, create nodes, populate node properties, query, and create relationships. My problem is that my "add relationship" and traversal code requires a node URIs as input. I can query for nodes and obtain the correct JSON describing the results, but I cannot seem to get the URI locations.
Here is a simplified version of my getUserByEmail code:
public URI getUserByEmail( String email )
{
System.out.println( "GETTING USER BY EMAIL [" + email + "]..." );
String queryStr = "MATCH (user) WHERE user.nodetype=\'user\' and user.email=\'" + email + "\' RETURN user";
WebResource webResource = client.resource( ROOT_URI + "/transaction/commit" );
String payload = "{\"statements\" : [ {\"statement\" : \"" + queryStr + "\"} ]}";
ClientResponse response = webResource
.accept( MediaType.APPLICATION_JSON )
.type( MediaType.APPLICATION_JSON )
.entity( payload )
.post( ClientResponse.class );
String responseStr = response.getEntity( String.class );
URI responseLocation = response.getLocation();
System.out.println( "RESPONSE STRING: " + responseStr );
System.out.println( "GOT USER AT: [" + responseLocation + "]" );
return responseLocation;
}
The JSON results come back fine and reflect what is in the graph db. The location, however, is always null.
The "add relationship" code that I am using works, as long as I have the URI to the start node. The code I have is based on the addRelationship() code that lives here: