Neo4j

Aus Claimbase (Testinstanz)
Zur Navigation springen Zur Suche springen

http://193.26.158.116:7474/

run neo4j

docker pull neo4j:latest

docker run -d \
  --name neo4j \
  -p 7474:7474 -p 7687:7687 \
  -v $HOME/neo4j/data:/data \
  -v $HOME/neo4j/import:/import \
  -e NEO4J_AUTH=neo4j/password \
  -e NEO4JLABS_PLUGINS='["apoc", "graph-data-science"]' \
  -e NEO4J_dbms_security_procedures_unrestricted=gds.*,apoc.* \
  -e NEO4J_apoc_import_file_enabled=true \
  -e NEO4J_apoc_import_file_use__neo4j__config=true \
  neo4j:latest

import data from json file

CALL apoc.load.json("file:///locations.json") YIELD value

// Create the Location node
MERGE (l:Location {id: value.id})
  SET l.name = value.name

// Create Regest nodes and relationships
WITH l, value
UNWIND value.lemmaID AS regestId
MERGE (r:Regest {id: regestId})
MERGE (l)-[:MENTIONED_IN]->(r);

Find clusters

CALL gds.graph.project(
  'myGraph',
  ['Person', 'Regest', 'Location'],
  {
    ALL: {
      type: '*',
      orientation: 'UNDIRECTED'
    }
  }
);
CALL gds.wcc.stream('myGraph')
YIELD nodeId, componentId
RETURN componentId, count(*) AS size
ORDER BY size DESC
LIMIT 1;
CALL gds.wcc.stream('myGraph')
YIELD nodeId, componentId
WHERE componentId = 0
RETURN gds.util.asNode(nodeId) AS node;

Keep Cluster Info: Persist Component IDs

CALL gds.wcc.write('myGraph', {
  writeProperty: 'componentId'
})
YIELD nodePropertiesWritten, componentCount;
CALL gds.graph.drop('myGraph');

Explore clusters via Property componentID

MATCH (n)
RETURN n.componentId AS component, count(*) AS size
ORDER BY size DESC
LIMIT 1;
MATCH (r:Regest)
WHERE r.componentId = 0
RETURN r;