In REST API for neo4j, how to merge or create nodes?

梦想的初衷 提交于 2019-12-12 03:22:16

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!