cypher

Path Query in neo4j

牧云@^-^@ 提交于 2019-12-25 10:15:49
问题 This question is based on my earlier post on neo4j I am trying to find out the names of the person living in city 'X'. I am using 2 nodes: Person and City for this purpose and a relationship exists [LIVES_IN]. I have created 4 nodes and 2 relationships as such: CREATE (m:Person { name : 'sa', paswrd : 'abc' }); CREATE (n:Person { name : 'ti', paswrd : 'abc' }); CREATE (o:City { name : 'pune' }); CREATE (p:City { name : 'mumbai' }); CREATE (m)-[:LIVES_IN]->(o); CREATE (n)-[:LIVES_IN]->(o); Now

Neo4j Query Performance tuning Undestanding

◇◆丶佛笑我妖孽 提交于 2019-12-25 09:16:51
问题 I am trying to optimize the query performance in my Neo4j. I have created the Unique indexes and the query is performing pretty good. But the query performance figure shown in the Neo4j web console shows as " 0 estimated rows " and " 0 db hits ". But in real, I am getting the result with one relationship. My query: Match (a:Person{id:"1234"})-[r:Employed_by]->(b:Organization(id:"abcd")) RETURN r This query returns me a relationship. But when I am checking the same query with Profile, it is

Neo4j - calculate & set node property based on relation property

孤者浪人 提交于 2019-12-25 09:06:57
问题 I want to know, if it's possible to calculate & set (update) a node property based relation properties (incoming&outgoing)? In my example, I would like to calculate an user personal "strength factor" (Kind of average) based on his relationships duration (int) divided by the count (int). Thanks for your help in advance, Cheers 回答1: Yes, it's possible. The only trick is that you have to use WITH to first perform the aggregation (for calculating the average): MATCH (n)-[r:RELTYPE]->() WITH n,

Neo4j/Cypher: Match on dynamic property

无人久伴 提交于 2019-12-25 08:38:17
问题 According to the developer manual section 3.2.4 on Parameters: Parameters cannot be used for the following constructs, as these form part of the >query structure that is compiled into a query plan: property keys; so, MATCH (n) WHERE n.$param = 'something' is invalid (source) Is there no way around this (c#, using the official driver)? I have a case where a node of a particular type can contain from a few up to hundreds of properties, and I want the users to be able to search for any of these

I need to count the number of connection between two nodes with a certain property

烂漫一生 提交于 2019-12-25 08:28:50
问题 My database contains informations about the nominations for the accademy awards. I want to know how many directors have won an oscar for "best director" more than one time. I can't quite get to the result that i want, a list of nominees. The closest I've been is with this query: MATCH (n:Nominee)-[n1:NOMINATED]->(c:Category) WHERE c.name="Best Director" AND n1.win=true RETURN count(n1.win), n.name ORDER BY n.name; wich returns the directors names and the number of times they won an oscar. I

Neo4j: MERGE creates duplicate nodes

北城以北 提交于 2019-12-25 08:11:22
问题 My database model has users and MAC addresses. A user can have multiple MAC addresses, but a MAC can only belong to one user. If some user sets his MAC and that MAC is already linked to another user, the existing relationship is removed and a new relationship is created between the new owner and that MAC. In other words, a MAC moves between users. This is a particular instance of the Cypher query I'm using to assign MAC addresses: MATCH (new:User { Id: 2 }) MERGE (mac:MacAddress { Value:

Extensions for Computationally-Intensive Cypher queries

纵然是瞬间 提交于 2019-12-25 07:31:16
问题 As a follow up to a previous question of mine, I want to find all 30 pathways that exist between two given nodes within a depth of 4. Something to the effect of this: start startnode = node(1), endnode(1000) match startnode-[r:rel_Type*1..4]->endnode return r limit 30; My database contains ~50k nodes and 2M relationships. Expectedly, the computation time for this query is very, very large; I even ended up with the following GC message in the message.log file: GC Monitor: Application threads

Neo4j - Get Level2 or Level3 connections

风格不统一 提交于 2019-12-25 07:27:48
问题 I'm developing a small connections structure to understand the concept of graph databases better, as well learn Neo4J I have few users and the relationship between them is KNOWS as follows I have the following cqls to create the nodes and relationships between then in Neo4j. CREATE (user1:User {name:"User1",mail:"user1@test.com",mobile: 9000090001}) CREATE (user2:User {name:"User2",mail:"user2@test.com",mobile: 9000090002}) CREATE (user3:User {name:"User3",mail:"user3@test.com",mobile:

Update multiple nodes in a single query, each with different property / value pairs

不羁的心 提交于 2019-12-25 07:19:57
问题 A similar question was answered by Michael Hunger in early 2013 however I am unable to translate his response to Neo4j/Cypher 3.x. https://groups.google.com/forum/#!msg/neo4j/qZWhbMtMCTE/r3W7OZfCgAgJ Each node has at a property with a UUID value. In some cases the "second" property is a Boolean, in other cases a string. I want to update some of these nodes, changing or adding a property to each one. (n1 {uuid:"foo1", enabled: true}) (n2 {uuid:"foo2", example: "foo"}) (n3 {uuid:"foo3"}) I

Neo4J: find a sub-graph of arbitrary depth with nodes connected by a given set of relations?

你说的曾经没有我的故事 提交于 2019-12-25 06:28:09
问题 How to build a Neo4J query that: 1) Will return all nodes in a sub-graph of arbitrary depth with nodes connected by a given set of relations? For example in Cypher-like syntax: MATCH (*)-[r1:FRIEND_OF AND r2:COLLEAGUE_WITH]->(*) RETURN * 回答1: This query will return just the nodes, as you stated in your question: MATCH (n)-[:FRIEND_OF|COLLEAGUE_WITH*]->(m) RETURN n, m; If you also want the relationships: MATCH (n)-[r:FRIEND_OF|COLLEAGUE_WITH*]->(m) RETURN n, r, m; 来源: https://stackoverflow.com