cypher

Neo4j Shortest Path for specific node labels in-between the path

时光怂恿深爱的人放手 提交于 2021-02-19 00:53:06
问题 I'm looking for a hint to solve the following issue: Given a Neo4j DB with two node types applied as labels :Address and :Milestone (one for each node) Between the different nodes there are directed :LEADS_TO relationships. Given the following pattern (I skipped the [ ] for the relations): Pattern 1: (a:Address)->(:Milestone)->(:Milestone)<-(:Milestone)<-(:Milestone)<-(b:Address) Pattern 2: (a:Address)->(:Milestone)->(c:Address)<-(:Milestone)<-(b:Address) I'm looking for a query that only

Cypher dynamic relationship with conditional APOC procedure?

前提是你 提交于 2021-02-17 05:34:05
问题 I am learning cypher and trying to find out a way to create dynamic relationship when a condition passes. Here is an example: we have single node: (n2) and another node which has unknown relationship of TEMP_1 or TEMP_2 with its child: (n1)------[TEMP_1 or TEMP_2]------>(child) we want to create relationship between (n2) and (child) if it exists (n2)------[TEMP_1 or TEMP_2]------>(child) Here is query: MATCH (n1: NODE_1) MATCH (n2: NODE_2) OPTIONAL MATCH (n1)-[rel:TEMP_1|TEMP_2]->(child) CALL

How to create nodes with variable labels in cypher?

我与影子孤独终老i 提交于 2021-02-10 18:49:18
问题 I am using JSON APOC plugin to create nodes from a JSON with lists in it, and I am trying to create nodes whose label is listed as an element in the list: { "pdf":[ { "docID": "docid1", "docLink": "/examplelink.pdf", "docType": "PDF" } ], "jpeg":[ { "docID": "docid20", "docLink": "/examplelink20.pdf", "docType": "JPEG" } ], ...,} And I want to both iterate through the doctypes (pdf, jpeg) and set the label as the docType property in the list. Right now I have to do separate blocks for each

Neo4J - Merge statement not creating new nodes with a relationship

南笙酒味 提交于 2021-02-08 11:44:15
问题 I have written a query which builds 2 new nodes if it exists then it just updates the properties and added a relationship between them. For the first time when I'm creating the nodes and relationship everything is going fine. // This is the first run MERGE (Kunal:PERSON) ON CREATE SET Kunal.name = 'Kunal', Kunal.type = 'Person', Kunal.created = timestamp() ON MATCH SET Kunal.lastUpdated = timestamp() MERGE (Bangalore: LOC) ON CREATE SET Bangalore.name = 'Bangalore', Bangalore.type = 'Location

Cypher: Shortest Path with Constraint

主宰稳场 提交于 2021-02-08 10:57:15
问题 I want to perform a shortest path query like the following: START source=node:myIndex(name="<src>"), destination=node:myIndex(name = "<dst>") MATCH p = shortestPath(source-[:REL1*..5]-destination), source-[sourceRel:REL1]-m, destination-[destRel:REL1]-k WHERE sourceRel.a=<someValue> and destRel.a=<someOtherValue> RETURN NODES(p); I want to get the shortest path between <src> and <dst> with the constraint that the property a has a certain value on the first relationship from src and dst

Cypher: Shortest Path with Constraint

谁都会走 提交于 2021-02-08 10:56:08
问题 I want to perform a shortest path query like the following: START source=node:myIndex(name="<src>"), destination=node:myIndex(name = "<dst>") MATCH p = shortestPath(source-[:REL1*..5]-destination), source-[sourceRel:REL1]-m, destination-[destRel:REL1]-k WHERE sourceRel.a=<someValue> and destRel.a=<someOtherValue> RETURN NODES(p); I want to get the shortest path between <src> and <dst> with the constraint that the property a has a certain value on the first relationship from src and dst

Modeling concept and its impact on the performance

社会主义新天地 提交于 2021-02-08 10:28:17
问题 I kindly ask to point out the pros and cons of the solutions that I came up with for the challenge described below. Getting into the details of neo4j internals like how things are stored or processed is more than welcome. I would appreciate for referring to the points e.g. U.2 / A.1.A for clear distinction. I have been designing model where we have two types of actors: User and Administrator. User of the system can: U.1) list both valid OR invalid (issued OR revoked) Invitations with

shortest path between 2 nodes through waypoints in neo4j

两盒软妹~` 提交于 2021-02-08 10:12:53
问题 I have a graph in neo4j where a node represents a city and a relationship represents roads connecting the cities. The relationships are weighted and have a property called 'distance'. I want to find the shortest (least weighted path) between two cities A and B. This is easily done using Dijkstra's algorithm. The tricky part is that I have a set of cities which are to be covered in the path from A to B. In other words, the path from A to B should cover all the waypoints, the order doesn't

shortest path between 2 nodes through waypoints in neo4j

ε祈祈猫儿з 提交于 2021-02-08 10:11:06
问题 I have a graph in neo4j where a node represents a city and a relationship represents roads connecting the cities. The relationships are weighted and have a property called 'distance'. I want to find the shortest (least weighted path) between two cities A and B. This is easily done using Dijkstra's algorithm. The tricky part is that I have a set of cities which are to be covered in the path from A to B. In other words, the path from A to B should cover all the waypoints, the order doesn't

Cypher temp relationship

浪子不回头ぞ 提交于 2021-02-08 08:24:08
问题 I'm trying to combine / merge a path into a new relationship. The problem is that I'm not interested in storing it but rather return it as a result of a cypher query. Lets say I have something like this: (a)-[:CALLS_METHOD]->(b)-[:RETURNS_TYPE]->(c) How can I create a temporary relationship like this one: (a)-[:DEPENDS_ON]->(c) Only for a result of that particular query, so that I don't have to store it. Because I'm really only interested in the dependency from a to c and not the details