Latest commit 1b75fe5 Jan 30, 2016 @sim51 sim51 [Cypher plugin]: PR #677
Change the package name of the plugin.
Permalink
..
Failed to load latest commit information.
LICENSE [Cypher plugin]: PR #677 Jan 30, 2016
README.md [Cypher plugin]: PR #677 Jan 30, 2016
sigma.neo4j.cypher.js [Cypher plugin]: PR #677 Jan 30, 2016

README.md

sigma.neo4j.cypher

Plugin developed by Benoît Simard.


This plugin provides a simple function, sigma.neo4j.cypher(), that will run a cypher query on a neo4j instance, parse the response, eventually instantiate sigma and fill the graph with the graph.read() method.

Nodes are created with the following structure :

  • id -> Neo4j node id
  • label -> Neo4j node id
  • neo4j_labels -> Labels of Neo4j node
  • neo4j_data -> All the properties of the neo4j node

Edges are created with the following structure :

  • id -> Neo4j edge id
  • label -> Neo4j edge type
  • neo4j_type -> Neo4j edge type
  • neo4j_data -> All the properties of Neo4j relationship

The most basic way to use this helper is to call it with a neo4j server url and a cypher query. It will then instantiate sigma, but after having added the graph into the config object.

For neo4j < 2.2

sigma.neo4j.cypher(
  'http://localhost:7474',
  'MATCH (n) OPTIONAL MATCH (n)-[r]->(m) RETURN n,r,m LIMIT 100',
  { container: 'myContainer' }
);

For neo4j >= 2.2, you must pass a neo4j user with its password. So instead of the neo4j url, you have to pass a neo4j server object like this :

sigma.neo4j.cypher(
  { url: 'http://localhost:7474', user:'neo4j', password:'admin' },
  'MATCH (n) OPTIONAL MATCH (n)-[r]->(m) RETURN n,r,m LIMIT 100',
  { container: 'myContainer' }
);

It is also possible to update an existing instance's graph instead.

sigma.neo4j.cypher(
  { url: 'http://localhost:7474', user:'neo4j', password:'admin' },
  'MATCH (n) OPTIONAL MATCH (n)-[r]->(m) RETURN n,r,m LIMIT 100',
  myExistingInstance,
  function() {
    myExistingInstance.refresh();
  }
);

There is two additional functions provided by the plugin :

  • sigma.neo4j.getTypes({ url: 'http://localhost:7474', user:'neo4j', password:'admin' }, callback) : Return all relationship type of the database
  • sigma.neo4j.getLabels({ url: 'http://localhost:7474', user:'neo4j', password:'admin' }, callback) : Return all node label of the database