Does neo4j have a trigger mechanism through Cypher? (similar to percolators in ElasticSearch)

I am looking for a method to store cypher requests and when adding nodes and relationships to be notified when it matches the specified request? Can this be done now? Something like ElasticSearch percolators would be great.

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-percolate.html

+8
neo4j cypher
source share
2 answers

Update

The answer below was accurate in 2014. It is mostly accurate in 2018.

But now there is a way to implement triggers in Neo4j provided by Max DeMarzi, which is very good, and it will do its job.

Original answer below.

No, it is not.

You might be able to get something similar to what you want using the TransactionEventHandler object, which basically allows you to bind a piece of code (in java) to process the transaction.

In this context, I would be very careful with starting cypher. Depending on what kind of correspondence you want to make, you can really cut performance by doing this every time new data is created on the chart. Typically, DBMS triggers are specific for inserts or updates in a particular table. In Neo4J, the closest equivalent you may have is to create / modify a node of a certain type of label. If your application has any number of different node classes, it would be pointless to run your startup code whenever new relationships / nodes are created, because most of the time the node type will probably not be related to the trigger code.

Related reading: Are database support triggers supported? and a function request for triggers in neo4j

+8
source share

Neo4j 3.5 supports triggers. To use this functionality, include apoc.trigger.enabled = true in $ NEO4J_HOME / config / neo4j.conf. You must add APOC to the server - it does not exist by default.

In a trigger, you register Cypher statements that are called when data changes in Neo4j (create, update, delete). You can run them before or after a commit.

Here is the dock help - https://neo4j-contrib.imtqy.com/neo4j-apoc-procedures/#triggers

0
source share

All Articles