cypher

Cypher: Matching nodes at arbitrary depth via a strictly alternating set of relations

十年热恋 提交于 2019-12-12 05:08:52
问题 I'm quite new to Cypher but struggling to find how to do this. I want to generalise the following so that it will match at an arbitrary depth. MATCH (:start)-[:a]-()-[:b]-(:end) //Depth1 MATCH (:start)-[:a]-()-[:b]-()-[:a]-()-[:b]-(:end) //Depth2 MATCH (:start)-[:a]-()-[:b]-()-[:a]-()-[:b]-()-[:a]-()-[:b]-(:end) //Depth3 MATCH (:start)-[:a]-()-[:b]-()-[:a]-()-[:b]-()-[:a]-()-[:b]-()-[:a]-()-[:b]-(:end) //Depth4 In other words, the path needs to pass through any number of a-node-b in strict

Neo4 giving error:“ Uncaught exception 'Everyman\Neo4j\Exception' with message 'Unable to retrieve server info [500]:”

倖福魔咒の 提交于 2019-12-12 05:05:15
问题 require('phar://neo4jphp.phar'); $client = new Everyman\Neo4j\Client(); if($client) { echo 'Connected'; } i am using neo4j version 1.9 RC1, i am able to access server via myip:7474, Curl is Enabled. Error is : couldn't connect Host[7] Please Help 回答1: In order to create the client, you must specify the transport you want to use, if you want to use Curl: $client = new Everyman\Neo4j\Client(new Everyman\Neo4j\Transport\Curl('localhost', 7474)); or with Stream: $client = new Everyman\Neo4j

using multiple match clauses doesn't return any result in neo4j cypher query

依然范特西╮ 提交于 2019-12-12 04:58:37
问题 I am executing the following two queries and i am getting some result. First query START person=node:NODE_TYPE(NODE_TYPE='PERSON') MATCH (person)-[?:contacts]->(var1)-[?:addresses]->(var2)-[?:details]->(var3)-[?:items]->(var4)-[?:items]->(var5)-[?:value]->(var6) WHERE var2.`#nodeId` ='at0000' and var3.`#nodeId` ='at0001' and var4.`#nodeId` ='at0002' and var5.`#nodeId` ='at0028' and var6.`value` =~'address.*' return distinct person; Second query START person=node:NODE_TYPE(NODE_TYPE='PERSON')

create a node in neo4j graph db with transaction endpoint

五迷三道 提交于 2019-12-12 04:50:00
问题 I know this is probably asked a hundred times and believe me, I read soooo much on the net already. But still, I am absolutely unapt to do this, so I'm in dire need of help here. What I want to do, is to create a node with label and properties in the neo4j db using cypher and the transactional endpoint - with the properties from a json. This is my code so far: /** * * @description creates a node in the graph * @param json object * @param label * */ private String createNodeObjectTransactional

How to delete nodes recursively from a start node

℡╲_俬逩灬. 提交于 2019-12-12 04:49:20
问题 I have a graph which has a set of nodes and its children. There is a root node from where the rest of the nodes branch out. There are few sets of such node collection. I want to pick a root node and clear all its connections and nodes recursively, leaving the root node for future additions. start n=node:DataSpace(DataSpaceName="DS1") match (ds)-[r]-(e) delete e,r The above Query is definitely wrong, as it does not consider recursion and also the condition that entities have to be deleted

Neo4j Cypher sort on collections

吃可爱长大的小学妹 提交于 2019-12-12 04:46:19
问题 I have a query (below) that returns collections of nodes containing create dates. I want to sort the rows by newest create date. Some of the rows have one create date, other rows have several. As can be seen, the node "name4" should be first. What corrections should I make to my query? Thanks. MATCH (node:node) WITH node ORDER BY node.created DESC RETURN count(node.name) AS count, node.name, collect(node.created) AS created count node.name created 3 "name1" [1410234609620,1410234606534

Neo4j Cypher delete query

梦想与她 提交于 2019-12-12 04:45:37
问题 I have a following Neo4j Cypher query for Decision entity deleting: MATCH (d:Decision) WHERE id(d) IN {decisionsIds} OPTIONAL MATCH (d)-[r]-(t) DELETE d, r WITH t, r WHERE NOT (id(t) IN {decisionsIds}) OPTIONAL MATCH (t)-[r2:VOTED_ON|:CREATED_BY|:VOTED_FOR]-() WHERE r2 <> r WITH t, r2 WHERE none(x in labels(t) WHERE x in ['User', 'Decision']) DELETE t, r2 Previously I had a Vote entity with relationships VOTED_ON and VOTED_FOR to entities Criterion and Decision . Also, Vote has relationship

Spring Data | Neo4J | Querying for the path in the correct order

北城余情 提交于 2019-12-12 04:38:15
问题 Versions: <dependency> <groupId>org.neo4j</groupId> <artifactId>neo4j-ogm-core</artifactId> <version>2.1.1</version> </dependency> <dependency> <!-- If you're using the HTTP driver --> <groupId>org.neo4j</groupId> <artifactId>neo4j-ogm-http-driver</artifactId> <version>2.1.1</version> </dependency> <!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-neo4j --> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-neo4j</artifactId> <version>4

Improve Neo4j Cypher Performance On Lengthy Match

女生的网名这么多〃 提交于 2019-12-12 04:25:30
问题 Setup: Neo4j - 1.9.3 ~7,000 nodes ~1.8 million relationships I have the following cypher query that I would like to improve the performance on: START a=node(2) MATCH (a)-[:knowledge]-(x)-[:depends]-(y)-[:knowledge]-(end) RETURN COUNT(DISTINCT end); This returns 471 (188171 ms). Right now I'm only getting a count but later I may want to get the values (471 in this example). The problem is it takes about 3-4 minutes to run. The graph is highly connected with many relationships. Running the

How can we copy labels from one node to another in one cypher?

旧巷老猫 提交于 2019-12-12 03:53:50
问题 The question is just as the title, and the cypher statement is just like the follow: Match (n: test) CREATE (copy : LABELS(n)) set copy = n Its purpose is to create a node with the same properties and same labels as the other node, but it doesn't work now because we cannot use a expression like LABELS(n) to set lobel to a node. How can I make it work? 回答1: Unfortunately, labels currently cannot be set directly from data values. 回答2: You could get the node's properties and labels you want to