cypher

Delete leaf nodes with single relationship in neo4j

与世无争的帅哥 提交于 2019-12-23 15:05:55
问题 I am trying to remove leaf nodes in Neo4j, but only those with a single incoming relationship. (I'm so close.) I have a query that returns the exact node I wish to remove. However, when I replace the RETURN with DELETE, it removes more than the query returns. Here's the complete sequence: neo4j-sh (?)$ match (n)-[r]->(p) return n, r, p ; +------------------------------------------------------------+ | n | r | p | +------------------------------------------------------------+ | Node[2164]{name

Recursive neo4j query

让人想犯罪 __ 提交于 2019-12-23 14:25:06
问题 I have a graph which has categories and sub-categories and sub-sub-categories to indefinite level. How I can I get all this hierarchical data in one cipher query? I currently have this query : START category=node:categoryNameIndex(categoryName = "category") MATCH path = category <- [rel:parentCategory] - subcategory RETURN category, collect(subcategory); Which gives me following result: | category | collect(subcategory) | ==> +------------------------------------------------------------------

Unexpected behavior combining collections in Cypher

拥有回忆 提交于 2019-12-23 14:04:11
问题 Using http://console.neo4j.org as a sandbox, I have come across the following unexpected behavior: Statement 1 - Returns 1 row with a collection containing Neo Node MATCH (n:Crew) WHERE n.name="Neo" WITH COLLECT(n) AS c1 WITH c1+[] AS c2 RETURN c2 Statement 2 - Returns 0 rows (unexpected) MATCH (n:Crew) WHERE n.name="Neo" WITH COLLECT(n) AS c1 MATCH (n:Crew) WHERE n.name="NoOne" WITH c1+COLLECT(n) AS c2 RETURN c2 Statement 3 - Returns 1 row containing an empty collection MATCH (n:Crew) WHERE

Recursive query with sub-graph aggregation (arbitrary depth)

老子叫甜甜 提交于 2019-12-23 09:25:19
问题 I asked a question earlier about aggregating quantities along a graph. The two answers provided worked well, but now I am trying to extend the Cypher query it to a graph of variable depth. To summarize we start of with a bunch of leaf stores which all are associated with a particular supplier, which is a property on the Store node. Inventory is then moved along to other stores and the proportion from each supplier corresponds to their contribution to the original store. So for node B02 , S2

How to write a Cypher query with a condition on one of relationship properties in Neo4j database?

眉间皱痕 提交于 2019-12-23 05:26:37
问题 My question: I am new to Neo4j and trying to create a query listing nodes and relationships into a graph with keyword as "id=0001" as below: (a) - [id:'0001', ref_id:null] -> (b) - [id:'0002', ref_id:'0001'] -> (c) - [id:'0003', ref_id:'0002'] -> (d) Start Node will be (a) since it has relationship with id=0001 But the database also exists relationships which I don't want: (a) - [id:'2001', ref_id:null] -> (b) - [id:'2002', ref_id:'2001'] -> (c) (a) - [id:'3001', ref_id:null] -> (b) - [id:

Loop in cypher, UNWIND or FOREACH (Neo4j)

隐身守侯 提交于 2019-12-23 05:14:30
问题 I have a relation in my neo4j database : (r:RateableEntity)<-[t:TAG]-(h:HashTags) Now I want to have a query that returns a list that includes: A list of hashtagName and their frequency in the database as hashtagCount and a list of items that related to this hashtags. hashtagName and hashtagItems have id label. Note: I'm receiving the number of hashtag and hashtagItems from input parameter as variable. And this is the result that I expected from my cypher query: "hashtagList": [ {

Neo4J - Optimizing 3 merge queries into a single query

末鹿安然 提交于 2019-12-23 05:05:49
问题 I am trying to make a Cypher query which makes 2 nodes and adds a relationship between them. For adding a node I'm checking if the node is existing or not, if existing then I'm simply going ahead and setting a property. // Query 1 for creating or updating node 1 MERGE (Kunal:PERSON) ON CREATE SET Kunal.name = 'Kunal', Kunal.type = 'Person', Kunal.created = timestamp() ON MATCH SET Kunal.lastUpdated = timestamp() RETURN Kunal // Query 2 for creating or updating node 2 MERGE (Bangalore: LOC) ON

how to have two aggregation in cypher query in neo4j?

人走茶凉 提交于 2019-12-23 05:05:04
问题 i have problem with complex queries; here is my cypher query: params.put("query", "name:*"); ExecutionResult result = engine.execute( "start n=node:groups({query}) match n<-[:Members_In]-x with n,count(distinct x) as numberOfUsers where numOfUsers>avg(numOfUsers) return n.name,numOfUsers ", params ); n is the group name and x is the users of each group. how can i have avg of group users count and compare it with each group users count? can I get the average number of group users and then

Load a large csv file into neo4j

久未见 提交于 2019-12-23 04:40:54
问题 I want to load a csv that contains relationships between Wikipedia categories rels.csv (4 million of relations between categories). I tried to modify the setting file by changing the following parameter values: dbms.memory.heap.initial_size=8G dbms.memory.heap.max_size=8G dbms.memory.pagecache.size=9G My query is as follows: USING PERIODIC COMMIT 10000 LOAD CSV FROM "https://github.com/jbarrasa/datasets/blob/master/wikipedia/data/rels.csv?raw=true" AS row MATCH (from:Category { catId: row[0]}

Load a large csv file into neo4j

北城余情 提交于 2019-12-23 04:40:10
问题 I want to load a csv that contains relationships between Wikipedia categories rels.csv (4 million of relations between categories). I tried to modify the setting file by changing the following parameter values: dbms.memory.heap.initial_size=8G dbms.memory.heap.max_size=8G dbms.memory.pagecache.size=9G My query is as follows: USING PERIODIC COMMIT 10000 LOAD CSV FROM "https://github.com/jbarrasa/datasets/blob/master/wikipedia/data/rels.csv?raw=true" AS row MATCH (from:Category { catId: row[0]}