Can I write a Neo4j Plugin to intercept and modify CYPHER queries -


in system, intercept , change cypher queries come in, 1 alternative modify them before sending them middle layer graph - there way have plugin conversion me in graph itself?

i'd of following: if identifying members of group a, imagine i'd change request from:

match(f:film)-[r:reviewed_by]-(u:user {id:"1337"}) 

to:

match(p:product)-[p:purchased_by]-(u:user {id:"1337"}) 

is possible? or have write traversals in java directly achieve this?

of course can. can in neo4j. grab cypher string in unmanaged extension receives post request, alter way want, execute graphdb.execute method , return result normal.

@post @path("/batch") public response altercypher(string body, @context graphdatabaseservice db) throws ioexception, interruptedexception {      arraylist<result> results = new arraylist<>();     // validate our input or exit right away     hashmap input = validators.getvalidcypherstatements(body);     arraylist<hashmap> statements = (arraylist<hashmap>)input.get("statements");     (hashmap statement : statements) {         // write alterquery method change queries.         string alteredquery = alterquery((string)statement.get("statement"));         result result = db.execute(alteredquery, (map)statement.getordefault("parameters", new hashmap<>()));         results.add(result);     }     // or go results , return them want      // see https://github.com/dmontag/neo4j-unmanaged-extension-template/blob/master/src/main/java/org/neo4j/example/unmanagedextension/myservice.java#l36     return response.ok().build(); } 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -