问题
I am running a local instance of neo4j ("Community" edition) on a Windows 10 laptop. My client is in Java and uses the REST API (via port 7474) to talk with the neo4j database.
QUESTION: is there some way to get the equivalent of a MERGE/CREATE
directive in cypher to happen via the REST API call to /db/data/node
endpoint?
I'm guessing that I could impose a unique constraint on different node types and achieve the desired behavior. But out of the box, what I am hoping for is a single endpoint -- Eg, /db/data/node
-- which either creates or merges the inbound data with any existing nodes in the graph.
回答1:
You don't have to figure out how to get the "equivalent" of Cypher clauses like MERGE/CREATE
. You can use Cypher directly via either of these REST endpoints:
- /db/data/transaction
- /db/data/cypher
[EDITED]
However, if you only want to use the /db/data/node
endpoint, you can take advantage of unique indexing and use either the uniqueness=get_or_create
or uniqueness=create_or_fail
URL parameters.
来源:https://stackoverflow.com/questions/32899411/in-rest-api-for-neo4j-how-to-merge-or-create-nodes