Reputation: 607
Now I am using RESTFul API to interface with Neo4j. My issue is: for example I have already created a Node1 in Neo4j. Then I just want to create a Node2 and a relationship to connect to Node1. I know I need to query node from Neo4j and return a node. But how to do it? I am new in Neo4j please help.
And I have already build a delete function by using java to delete all nodes and relationships in Neo4j. Here is my code:
public String deleteAllNodeOrRelation() throws ClientHandlerException,
UniformInterfaceException, JDOMException {
String cypherPayload = "{\"query\": \"START a=node(*) MATCH a-[r?]-() DELETE a,r RETURN a\", \"params\":{}}";
String user_name = getUserName(cypherPayload);
return user_name;
}
is the query node function similar with this delete function? and to be noticed, I have properties stored in each node. The property name is "title". Someone told me I can query "title" to search and return the node1. But I still dont know how to do it....
Upvotes: 0
Views: 110
Reputation: 41676
Yes, you would have to enable auto-indexes for your domain-keys just do:
START u1=node:node_auto_index(name={user1}),
u2=node:node_auto_index(name={user2})
CREATE (u1)-[:KNOWS]->(u2)
you pass user1
and user2
as parameters to your function and to the cypher query call.
For some ways of how to call cypher from Java see: https://github.com/jexp/cypher-http-examples
Upvotes: 0