Create a graph object (map) from information that’s passed in.
It’s basic structure is: {name:"Name",properties:{properties},nodes:[nodes],relationships:[relationships]}
|
creates a virtual graph object for later processing it tries its best to extract the graph information from the data you pass in |
|
creates a virtual graph object for later processing |
|
creates a virtual graph object for later processing |
|
creates a virtual graph object for later processing |
|
creates a virtual graph object for later processing |
|
creates a virtual graph object for later processing |
|
aggregates graph elements to a "graph" map with unique sets of "nodes" and "relationships" |
Create a graph object (map) from information that’s passed in.
It’s basic structure is: {name:"Name",properties:{properties},nodes:[nodes],relationships:[relationships]}
|
creates a virtual graph object for later processing it tries its best to extract the graph information from the data you pass in |
|
creates a virtual graph object for later processing |
|
creates a virtual graph object for later processing |
|
creates a virtual graph object for later processing |
|
creates a virtual graph object for later processing |
|
creates a virtual graph object for later processing |
|
transform JSON documents into graph structures |
|
validate the JSON and returns informations about required fields violations |
The procedure apoc.graph.fromDocument
transforms a JSON into a graph structure. It takes two arguments:
id
and a type
(name of Label), configurable via the config params.
The value can be a String, or Cypher Map or List of Maps.
Currently spatial and datetime properties are not handled yet. More advanced configuration for mapping the document is coming in future versions.
The config is composed by the following parameters:
{
"id": 1,
"type": "artist",
"name": "Genesis",
"members": ["Tony Banks", "Mike Rutherford", "Phil Collins"],
"years": [1967, 1998, 1999, 2000, 2006]
}
In this case it create one Node
with labels Artist
It also accepts list of documents:
[{
"id": 1,
"type": "artist",
"name": "Genesis",
"members": ["Tony Banks", "Mike Rutherford", "Phil Collins"],
"years": [1967, 1998, 1999, 2000, 2006]
}, {
"id": 2,
"type": "artist",
"name": "Daft Punk",
"members": ["Guy-Manuel de Homem-Christo", "Thomas Bangalter."],
"years": [1987, 1993, 1999, 2004, 2008, 2011]
}]
In this case it create 2 Node
with labels Artist
JSON Tree to graph:
{
"id": 1,
"type": "artist",
"name": "Genesis",
"albums": [{
"type": "album",
"id": 1,
"producer": "Jonathan King",
"title": "From Genesis to Revelation"
}]
}
In this case it will create 2 Node
, one Artist and one Album connected to each other by the ALBUMS Relationship
We create a dataset for our examples
CREATE (a:Actor {name:'Tom Hanks'})-[r:ACTED_IN {roles:'Forrest'}]->(m:Movie {title:'Forrest Gump'}) RETURN *
Virtual graph from data.
MATCH (n)-[r]->(m) CALL apoc.graph.fromData([n,m],[r],'test',{answer:42}) YIELD graph RETURN *
Virtual graph from path.
MATCH path = (n)-[r]->(m) CALL apoc.graph.fromPath(path,'test',{answer:42}) YIELD graph RETURN *
Virtual graph from paths.
MATCH path = (n)-[r]->(m) CALL apoc.graph.fromPaths([path],'test',{answer:42}) YIELD graph RETURN *
Virtual graph from DB.
CALL apoc.graph.fromDB('test',{answer:42}) YIELD graph RETURN *
Virtual graph from Cypher.
CALL apoc.graph.fromCypher('MATCH (n)-[r]->(m) RETURN *',null,'test',{answer:42}) YIELD graph RETURN *
As a result we have a virtual graph object for later processing
Virtual graph from JSON.
CALL apoc.graph.fromDocument("{'id': 1,'type': 'artist','name':'Genesis','members': ['Tony Banks','Mike Rutherford','Phil Collins'],'years': [1967, 1998, 1999, 2000, 2006],'albums': [{'type': 'album','id': 1,'producer': 'Jonathan King','title': 'From Genesis to Revelation'}]}", false) yield graph return graph
As a result we have a virtual graph with two nodes and one relationship: