neo4j

create relationship and merge node in loop in neo4j

不羁岁月 提交于 2020-01-04 23:46:42
问题 I am trying to create a relationship in loop from both top list and bottom list .I am trying to connect the top loop with the bottom loop .I really appreciate any help.Thanks. UNWIND [{id:"1",name:"b1",year:"2010"}, {id:"2",name:"d1",year:"2011"}, {id:"3",name:"e1",year:"2013"}] as user MERGE (u:User {id: user.id, name: user.name,year:user.year}) UNWIND [{id:"21",name:"b",year:"2010"}, {id:"41",name:"d",year:"2011"}, {id:"51",name:"e",year:"2013"}] as w MERGE (y:W {id: w.id, name: w.name,year

variable length matching over paths in Cypher

亡梦爱人 提交于 2020-01-04 18:12:06
问题 Is it possible to allow variable length matching over multiple paths in Cypher? By a path I mean something like two KNOWS traversals or three BLOCKS traversals, where KNOWS and BLOCKS are relationship types in my graph. For example, I'd like to be able to write something like: MATCH (s)-[r*]->(t) WHERE ALL (x in type(r) WHERE x=KNOWS/KNOWS OR x= BLOCKS/BLOCKS/BLOCKS) RETURN s, t where by "KNOWS/KNOWS" I mean something like (a)-[:KNOWS]->(b)-[:KNOWS]->(c). I want to do this without changing

Neo4j gem - Detailed Querying direction with has_many: both

故事扮演 提交于 2020-01-04 17:34:55
问题 I was able to do a specific pattern match from this original question Neo4j gem - Preferred method to deal with admin relationship via this Event.query_as(:event).match("(event)<-[invite:invited]-(user1:User)<-[friends_with:friends_with]-(user2:User)").where('invite.admin = true').pluck(:event) I was unable to get a modified version such as this to work current_user.friends.events.query_as(:event).match("(event)<-[invite:invited]-(user:User)").where(invite: {admin: true}).pluck(:event) So

Neo4j gem - Detailed Querying direction with has_many: both

送分小仙女□ 提交于 2020-01-04 17:34:06
问题 I was able to do a specific pattern match from this original question Neo4j gem - Preferred method to deal with admin relationship via this Event.query_as(:event).match("(event)<-[invite:invited]-(user1:User)<-[friends_with:friends_with]-(user2:User)").where('invite.admin = true').pluck(:event) I was unable to get a modified version such as this to work current_user.friends.events.query_as(:event).match("(event)<-[invite:invited]-(user:User)").where(invite: {admin: true}).pluck(:event) So

Neo4j Cypher query performance optimization

試著忘記壹切 提交于 2020-01-04 14:02:31
问题 I have the following Neo4j Cypher query MATCH (dg:DecisionGroup)-[:CONTAINS]->(childD:Decision) WHERE dg.id = 1 MATCH (childD)-[relationshipValueRel4:HAS_VALUE_ON]-(filterCharacteristic4:Characteristic) WHERE filterCharacteristic4.id = 4 WITH relationshipValueRel4, childD, dg WHERE (ANY (id IN [2,3] WHERE id IN relationshipValueRel4.optionIds )) WITH childD, dg OPTIONAL MATCH (childD)-[vg:HAS_VOTE_ON]->(c:Criterion) WHERE c.id IN [2, 3] WITH childD, dg, vg.avgVotesWeight as weight, vg

finding shortest path that excludes particular edges?

孤街浪徒 提交于 2020-01-04 09:58:06
问题 I'm using Py2neo, but that probably doesn't matter since this will most likely need to be done by writing a Cypher query. Essentially, I want to find a shortest path in a subgraph , where the subgraph is most of the whole graph but with a very small fraction (a millionth or less) of the edges removed. For example, say I have nodes A, B, and C, and edges (A->B), (A->C), (B->C). Of course, the shortest path from A to C is via the direct connection. But if I wanted to find the shortest path that

finding shortest path that excludes particular edges?

◇◆丶佛笑我妖孽 提交于 2020-01-04 09:57:50
问题 I'm using Py2neo, but that probably doesn't matter since this will most likely need to be done by writing a Cypher query. Essentially, I want to find a shortest path in a subgraph , where the subgraph is most of the whole graph but with a very small fraction (a millionth or less) of the edges removed. For example, say I have nodes A, B, and C, and edges (A->B), (A->C), (B->C). Of course, the shortest path from A to C is via the direct connection. But if I wanted to find the shortest path that

Searching for node in py2neo

对着背影说爱祢 提交于 2020-01-04 09:38:12
问题 Is there a way to search for a node with a specific property using py2neo? (I have a bunch of nodes with {"word": "some word"}, and I want to be able to search through nodes to find a node whose word attribute has a specific value) 回答1: I suggest that you consider using an index for this kind of requirement. You can index the nodes against the properties you need to search for and then refer to this index for your search. Otherwise, you're left with a reasonably non-performant Cypher query:

Neo4j 2.0 dump with double type

荒凉一梦 提交于 2020-01-04 09:30:15
问题 On Neo4j 2.0 (community) when I dump a db with some nodes with Double type properties, I obtain a file with value in scientific notation : ex 1.43524185E8 On import of this file, the neo4j-shell fail with the following error : Invalid input 'E': expected Digit, whitespace, '.', node labels, '[', "=~", IN, IS, '*', '/', '%', '^', '+', '-', '<', '>', "<=", ">=", '=', "<>", "!=", AND, XOR, OR, ',' or '}' (line 167, column 153) "create (_30015:`organization`:`fr` {`capital`:1.43524185E8, })" ^ at

Batching in py2neo

限于喜欢 提交于 2020-01-04 09:10:26
问题 I have started working with Node4j and I was exploring a bit the batch processing, but unfortunately, I am having some problems in creating relations between nodes. My problem is the following. I have a list of websites and users that I read from a file. I may have repeated websites and users in that file, so I do not want to insert new nodes for those repeated entries. But as the file is big, I want to batch the processing of the nodes and relations. Basically, I have these two functions to