cypher

Add properties to Neo4j Dynamically

你离开我真会死。 提交于 2020-01-04 04:04:25
问题 How to add a new property dynamically to an existing node ? Here I wan to assign both key and value dynamically to my chypher query.. Any suggestions will be highly appreciated :) 回答1: You can create a map with key value pairs and add the pairs with SET . Example 1: Add properties, will erase the others WITH {name:"Kenny", age:10} as kv MATCH (n:Person {uid:"123-fff"}) SET n = kv Example 2: Append properties, will replace values of existing keys : WITH {name:"Kenny", age:10} as kv MATCH (n

Add properties to Neo4j Dynamically

ε祈祈猫儿з 提交于 2020-01-04 04:04:08
问题 How to add a new property dynamically to an existing node ? Here I wan to assign both key and value dynamically to my chypher query.. Any suggestions will be highly appreciated :) 回答1: You can create a map with key value pairs and add the pairs with SET . Example 1: Add properties, will erase the others WITH {name:"Kenny", age:10} as kv MATCH (n:Person {uid:"123-fff"}) SET n = kv Example 2: Append properties, will replace values of existing keys : WITH {name:"Kenny", age:10} as kv MATCH (n

Add properties to Neo4j Dynamically

天大地大妈咪最大 提交于 2020-01-04 04:04:06
问题 How to add a new property dynamically to an existing node ? Here I wan to assign both key and value dynamically to my chypher query.. Any suggestions will be highly appreciated :) 回答1: You can create a map with key value pairs and add the pairs with SET . Example 1: Add properties, will erase the others WITH {name:"Kenny", age:10} as kv MATCH (n:Person {uid:"123-fff"}) SET n = kv Example 2: Append properties, will replace values of existing keys : WITH {name:"Kenny", age:10} as kv MATCH (n

Neo4j Cypher : transfer all relationships before replacing a node by another

大憨熊 提交于 2020-01-04 03:25:22
问题 I'm trying to transfert all ingoing and outgoing relationships from a node to another, before deleting the first one. they both have the same label. I saw this Neo4j Cypher: copy relationships and delete node but in my case i don't know the type of the relations and i want to transfer both ingoing and outgoing ones. i'm looking for either a cypher query or a query based on neo4j.rb 回答1: I don't think that this is possible with pure cypher. Here's a solution using neo4j.rb that I think will

Return value after deleting node or relationship in neo4j

馋奶兔 提交于 2020-01-03 18:21:52
问题 I have experienced that when I delete some node (which may have relationships) or relationship in neo4j using cypher query, it do not give anything in return like in mysql db. is there any way which can give the confirmation about the number of affected node (like number of node deleted) in cypher ? 回答1: Below query works (I have tried this with neo4j 1.8.1 and 1.9.3 both community and enterprise version) START root=node(1) MATCH root-[r:?]->() WHERE root.Id=12 DELETE r,root return count(root

Return value after deleting node or relationship in neo4j

我们两清 提交于 2020-01-03 18:21:12
问题 I have experienced that when I delete some node (which may have relationships) or relationship in neo4j using cypher query, it do not give anything in return like in mysql db. is there any way which can give the confirmation about the number of affected node (like number of node deleted) in cypher ? 回答1: Below query works (I have tried this with neo4j 1.8.1 and 1.9.3 both community and enterprise version) START root=node(1) MATCH root-[r:?]->() WHERE root.Id=12 DELETE r,root return count(root

Neo4j match multiple relationships

穿精又带淫゛_ 提交于 2020-01-03 17:34:27
问题 How can I write a query that gets nodes that have relationships to ALL nodes of a set. For example: START n=node:people("username:*"), g=node:groups("groupname:A groupname:B") MATCH n-[:M]->g RETURN n This returns users that have relationships to A or B. But I want users that have relationships to A and B. I can't figure out how to do it though. Edit: I need to do this for an arbitrary number of groups, not just A and B. And the reason I'm using index syntax is that this is from user input,

Neo4j/Cypher effective pagination with order by over large sub-graph

故事扮演 提交于 2020-01-03 16:43:33
问题 I have following simple relationship between (:User) nodes. (:User)-[:FOLLOWS {timestamp}]->(:User) If I paginate followers ordered by FOLLOWS.timestamp I'm running into performance problems when someone has millions of followers. MATCH (u:User {Id:{id}})<-[f:FOLLOWS]-(follower) WHERE f.timestamp <= {timestamp} RETURN follower ORDER BY f.timestamp DESC LIMIT 100 What is suggested approach for paginating big sets of data when ordering is required? UPDATE follower timestamp --------------------

Neo4j Cypher Get Relationship Direction

最后都变了- 提交于 2020-01-03 15:35:43
问题 I have following cypher query which returns all (in and out) relationships of an specific node: START s=node(1) MATCH s<-[r]->(t) RETURN type(r) as RelationshipType, ....... Now I want to find out the direction of each relationship. Is there an command like " RETURN RelationshipDirection(r) " ?? :) Thanks. 回答1: Per neo4j 2.0, you can use startnode(r) See http://docs.neo4j.org/chunked/snapshot/query-functions-scalar.html#functions-startnode STARTNODE returns the starting node of a relationship

neo4j merge 2 or multiple duplicate nodes

主宰稳场 提交于 2020-01-03 10:24:17
问题 I am feeding my neo4j db manually using cypher, so prone to error like creating duplicate nodes: The duplicate nodes will have each relationships to other nodes. Is there a built-in function to merge these nodes? Or should I do it manually? Sounds possible, but complicated with cypher script: Get the relationships of each duplicate node Recreate them (with their properties) with the correct node (given node id) Remove relationships to the duplicate nodes and finally remove the duplicate nodes