cypher

How to create nodes and relationships from csv in neo4j

一世执手 提交于 2020-03-12 05:59:57
问题 I am loading a csv file with cypher query. The csv file is having 4 columns. 2 for columns and 2 for tables as shown below. I want to create 2 types of nodes database and tables from those 4 columns. How can I create unique nodes for database and columns and to have relationships between them? As per logisima's answer I added below query to create nodes for database and columns and added relationships. But there is some duplication in nodes. `LOAD CSV WITH HEADERS FROM 'file:///test1.csv' AS

How to identify a sorted list

蹲街弑〆低调 提交于 2020-02-25 13:39:08
问题 I want to know whether a list "A" has already been sorted by its values (in strictly ascending order). I thought about making a copy of the list (=> "B") and comparing it to "A" ordered by its values (using ASC ). At the current state, I have no idea how to create a copy of a list. Maybe there is another easier way to solve this problem (using Cypher). 回答1: If you don't want to/can't use APOC you can sort the list by using UNWIND list as item WITH list,item ORDER BY item It is a bit clunky

How to identify a sorted list

非 Y 不嫁゛ 提交于 2020-02-25 13:36:25
问题 I want to know whether a list "A" has already been sorted by its values (in strictly ascending order). I thought about making a copy of the list (=> "B") and comparing it to "A" ordered by its values (using ASC ). At the current state, I have no idea how to create a copy of a list. Maybe there is another easier way to solve this problem (using Cypher). 回答1: If you don't want to/can't use APOC you can sort the list by using UNWIND list as item WITH list,item ORDER BY item It is a bit clunky

Error in inserting a string parameter to a cypher query in a java code

懵懂的女人 提交于 2020-02-07 07:09:04
问题 I want to insert a string parameter to a cypher query in Java. Below is the code I used and I have a person node named 'piyumi' and I want to make relationship with an activity node. The name of the activity node is 'walking'. When I execute the code I get http status code 400. Can anyone help me to modify the cypher query so that I can insert the string variable s without error. import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey

neo4j : CALL APOC.LOAD.HTML with HEADERs

时光怂恿深爱的人放手 提交于 2020-02-05 01:11:49
问题 I have the following table <table> <tr> <th> header 1</th> <th> header 2</th> <th> header 3</th> <tr> <td> keyword1 </td> <td> value1.2 </td> <td> <p> paragraph 1 </p> </td> </tr> <tr> <td> keyword2 </td> <td> value2.2 </td> <td> <p> paragraph 2 </p> <p> paragraph 3 </p> </td> </tr> <tr> <td> keyword3 </td> <td> value3.2</td> <td> <p> paragraph 1 </p> <p> paragraph 3 </p> <p> </p> </td> </tr> </table> What method you suggest to use to load it via apoc.load.html and apoc.node.create or apoc

neo4j : CALL APOC.LOAD.HTML with HEADERs

橙三吉。 提交于 2020-02-05 01:11:22
问题 I have the following table <table> <tr> <th> header 1</th> <th> header 2</th> <th> header 3</th> <tr> <td> keyword1 </td> <td> value1.2 </td> <td> <p> paragraph 1 </p> </td> </tr> <tr> <td> keyword2 </td> <td> value2.2 </td> <td> <p> paragraph 2 </p> <p> paragraph 3 </p> </td> </tr> <tr> <td> keyword3 </td> <td> value3.2</td> <td> <p> paragraph 1 </p> <p> paragraph 3 </p> <p> </p> </td> </tr> </table> What method you suggest to use to load it via apoc.load.html and apoc.node.create or apoc

Neo4j Cypher — limit for “in” clause in query

老子叫甜甜 提交于 2020-01-30 12:58:05
问题 I am working on a cypher query fetching nodes which are present in the path and so we are providing start node and list of nodes which are expected in the path and expected result is the nodes from the provided list. Can you please suggest what is the limit of in clause in Neo4j like we have limit of 2100 in sql. Example query : MATCH (n:person{key:2529962, ownBy:0}) MATCH path = n<-[:relation]-(c:Equipment) WHERE c.key in [1505697,2406945,2408297,2408531,2410815,2413566,2415224,] RETURN

How to efficiently find multiple relationship size

拟墨画扇 提交于 2020-01-25 09:14:04
问题 We have a large graph (over 1 billion edges) that has multiple relationship types between nodes. In order to check the number of nodes that have a single unique relationship between nodes (i.e. a single relationship between two nodes per type, which otherwise would not be connected) we are running the following query: MATCH (n)-[:REL_TYPE]-(m) WHERE size((n)-[]-(m))=1 AND id(n)>id(m) RETURN COUNT(DISTINCT n) + COUNT(DISTINCT m) To demonstrate a similar result, the below sample code can run on

Neo4J cypher: collect intermediate node properties (path)

放肆的年华 提交于 2020-01-25 07:58:09
问题 I have a data lineage related graph in Neo4J with variable length path containing intermediate nodes (tables): match p=(s)-[r:airflow_loads_to*]->(t) where s.database_name='hive' and s.schema_name='test' and s.name="source_table" return s.name,collect(nodes(p)),t.name Instead of returning the nodes between s.name and t.name as a path, I want to return an array of the name property of all nodes in the path (in the order of traversing) I probably have to use collect, but that is not possible on

How to use SQL-like GROUP BY in Cypher query language, in Neo4j?

不问归期 提交于 2020-01-25 02:17:04
问题 I want to find the number of all users in a company and the number of its men and women. My query is: start n=node:company(name:"comp") match n<-[:Members_In]-x, n<-[:Members_In]-y where x.Sex='Male' and y.Sex='Female' return n.name as companyName, count(distinct x) as NumOfMale, count(distinct y) as NumOfFemale" ); My query is correct, but I know I shouldn't use n<-[:Members_In]-y in the match clause. How can I get the number of male, number of female, and total number of users? 回答1: Peter