neo4j

Why can't I set the Id for a new vertex using Gremlin in Java?

天大地大妈咪最大 提交于 2019-12-11 03:46:55
问题 I'm using Gremlin with Java and a Neo4j graph. I create 3 new vertices and try to set their Ids to 1,2,3 but it does not seem to be working, what am I doing wrong? Vertex v1 = g.addVertex(1); v1.setProperty("name","jim"); Vertex v2 = g.addVertex(2); v2.setProperty("name","bob"); Vertex v3 = g.addVertex(3); v3.setProperty("name","fred"); //iterate through the vertices and get their id's (shouldn't they be 1,2, and 3 ?? for (Vertex V:GVs) System.out.println(V.getId()); returns: 15 16 17 Why is

Loading relationships from CSV data into neo4j db

浪尽此生 提交于 2019-12-11 03:45:29
问题 Neo4j 2.1.7 Attempting to mass-connect a bunch of nodes via information I've received in a CSV, which looks like: person_id,book_id,relationship 111,AAA,OWNS 222,BBB,BORROWS 333,AAA,BORROWS The nodes :Person and :Book used in this CSV were successfully loaded via LOAD CSV and CREATE statements, and already exist in the database. Now, I'd like to load this above CSV of relationships between :Person and :Book . The relationships are defined in the CSV itself. LOAD CSV WITH HEADERS FROM "file

Return my friends and friends of friends using Neo4j's Cypher

大兔子大兔子 提交于 2019-12-11 03:37:54
问题 I have nodes with bi-relations(follow) I am trying to create a query which I want to return all following nodes of a specific node and the following nodes of his following nodes(3 hopes depth) For example assume those relations: -> symbols follow A->B B->A B->C C->B C->D D->C C->E E->C I am expecting to get this response if I execute the query on node A B C D E I tried this: MATCH (user:User {name:'roi'})-[:nearby*1..3]->(foaf) WHERE NOT((user)-[:nearby]->(foaf)) RETURN user, foaf the problem

Spring Web Security locks Neo4j embedded database

删除回忆录丶 提交于 2019-12-11 03:37:30
问题 In continue to my previous issue Neo4j Embedded database hangs after abnormal application termination I noticed that everything works properly if I use graphDatabaseService.shutdown(); method before terminating of my application.. Otherwise after restart my application hangs on the database operations. After hours of investigation I think, I have found the general source of this issue but have no idea right now how to fix it. This is my Spring Boot WebSecurityConfig : @Configuration

Neo4j export Tree

点点圈 提交于 2019-12-11 03:35:38
问题 I want to export a Tree which has a distinct root node. I tried it with gremlin (g.saveGraphML("export.graphml")) but this is exporting the whole database. Then I tried it with g.v(783095).saveGraphML("export.graphml") which gave me an error (No signature of method: java.util.HashMap.saveGraphML() is applicable for argument types: (java.lang.String) values: [export.graphml]) Any Ideas? 回答1: Try to create a subgraph of g into a temporary graph structure and then save that one. g = new

Using regex capture groups in a Cypher query

左心房为你撑大大i 提交于 2019-12-11 03:22:02
问题 In the cypher documentation it says you can use regexes to match particular -previously known- patterns in a string attribute. Is it possible to use capture groups as well? Take an example: My node attributes are serialised JSON that look like: n.json = '{"name": "John", "gender": "m"}' n.json = '{"name": "Jane", "gender": "f"}' I want to know relationships between people of different gender: MATCH r=(n)--(m) WHERE NOT (n.json =~ '.*gender": "(\c)".*')[1] = (m.json =~ '.*gender": "(\c)".*')[1

Parameterizing labels

杀马特。学长 韩版系。学妹 提交于 2019-12-11 03:19:34
问题 Is it possible to add a label to a new node in Neo4j using parameters? For example: CREATE (N){nodeLabel} With parameters: nodeLabel = "Widget" I've attempted to do this but have only seen exceptions. 回答1: Currently labels cannot be parameterized. Feel free to file a feature request on https://github.com/neo4j/neo4j/issues/new. 回答2: In short - no. See also this post on Google Groups where I have a poor workaround (for Java/SDN anyway). Whoo hoo, issue 2000 created to request this feature 来源:

spring-data-neo4j remove nodeEntity and all referenced nodes

南笙酒味 提交于 2019-12-11 03:17:58
问题 I've got a simple graph model: 1 User has N SocialUser . I'm wondering if there is any way through spring-data-neo4j to automatically delete all SocialUser referenced when I remove an User entity. This is what I've got so far: Domain: @NodeEntity public class User implements IdentifiableEntity<String> { @GraphId private Long nodeId; // ... @RelatedTo(type = "HAS", direction = Direction.OUTGOING) Set<SocialUser> socialUsers = new HashSet<>(); } @NodeEntity public class SocialUser implements

Cypher: Extract unique values from collection

自古美人都是妖i 提交于 2019-12-11 03:16:50
问题 I have MATCH (x)-[rels*]->(y) RETURN extract( r in rels | r.property) as collected where collected is a collection of properties of all relationships along the path, such as [null, 4, null, 4] or [1, 3, 3, 1] . How can I further extract from collected only its unique values? For example, [null, 4, null, 4] would change into [null, 4] 回答1: try this instead: MATCH (x)-[rels*]->(y) UNWIND rels AS rel RETURN COLLECT( distinct rel.property) AS collected 来源: https://stackoverflow.com/questions

Query writing performance on neo4j with py2neo

心已入冬 提交于 2019-12-11 03:14:58
问题 Currently im struggle on finding a performant way, running multiple queries with py2neo. My problem is a have a big list of write queries in python that need to be written to neo4j. I tried multiple ways to solve the issue right now. The best working approach for me was the following one: from py2neo import Graph queries = ["create (n) return id(n)","create (n) return id(n)",...] ## list of queries g = Graph() t = graph.begin(autocommit=False) for idx, q in enumerate(queries): t.run(q) if idx