cypher

Cypher query vs cypher dsl in spring data neo4j

╄→尐↘猪︶ㄣ 提交于 2020-01-16 19:18:08
问题 I want to know about neo4j dsl recommendation in Spring data neo4j framework. As of now I used to create repository interface extending from GraphRepository , NamedIndexRepository etc. and write my custom methods with my custom cypher query with @Query annotation as below: @Query(value="START root=node:__types__(className='com.data.EntityNode') WHERE root.id={0} and " + "root.type={1} return root") T findByIdAndType(String id, String type); above method works nicely as far as I consider the

Weird Neo4J Cypher behavior on setting relationship properties

白昼怎懂夜的黑 提交于 2020-01-16 16:11:11
问题 I have a Cypher request for Neo4J of this kind: MATCH (u:User {uid: $userId}) UNWIND $contextNames as contextName MERGE (context:Context {name:contextName.name,by:u.uid,uid:contextName.uid}) ON CREATE SET context.timestamp=$timestamp MERGE (context)-[by:BY]->(u) SET by.timestamp = $timestamp My params are: { "userId": "15229100-b20e-11e3-80d3-6150cb20a1b9", "contextNames": [ { "uid": "822e2580-1f5e-11e9-9ed0-5b93e8900a78", "name": "fnas" } ], "timestamp": "1912811921129" } That query above

Is there sth like `eval` in Neo4j?

爷,独闯天下 提交于 2020-01-16 09:05:33
问题 Can I evaluate cypher code from a string in Neo4j? I think about something like eval function in JavaScript. 回答1: You will be helped by the apoc library with a rich set of tools to execute the cypher from the string: call db.labels() yield label call apoc.cypher.run("match (:`"+label+"`) return count(*) as count", null) yield value return label, value.count as count 来源: https://stackoverflow.com/questions/55433173/is-there-sth-like-eval-in-neo4j

Neo4J cypher: remove loops from flattened resultset

回眸只為那壹抹淺笑 提交于 2020-01-16 08:35:33
问题 This is an extension of the following question: I have a data lineage related graph in Neo4J with variable length path containing intermediate nodes (tables) as an array: 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, [n in nodes(p) | n.name] as arrayOfName,t.name Now, this resultset contains loops that I want to omit . I can ' remove ' these loops without the flattening ArrayOfName result by running: match

Creating relationships between nodes with WHERE clause and using ID in Neo4j

こ雲淡風輕ζ 提交于 2020-01-15 19:17:17
问题 I have two nodes named Room(4) and Houses(4). They have been created in the following way: CREATE (n:Room { code: 1}) CREATE (n:Room { code: 1}) CREATE (n:Room { code: 1}) CREATE (n:Room { code: 1}) CREATE (n:House { code: 1}) CREATE (n:House { code: 2}) CREATE (n:House { code: 3}) CREATE (n:House { code: 4}) These are some of the relations that i am trying to create between the nodes MATCH (room:Room), (house:House{code:1}) WHERE id(room) = 40 CREATE UNIQUE (room)-[:PLACED_IN]->(house) ;

Not null attribute in Neo4J constraint

杀马特。学长 韩版系。学妹 提交于 2020-01-15 08:41:26
问题 It is possible to create constraint in Neo4J database for attribute to be not null? Something like: CREATE CONSTRAINT ON (p:Person) ASSERT p.name IS NOT NULL 回答1: It's planned and been already implemented for Neo4j 2.3, should be available with 2.3.RC1 来源: https://stackoverflow.com/questions/31439614/not-null-attribute-in-neo4j-constraint

neo4j EntityNotFound prevents cypher match from working

浪子不回头ぞ 提交于 2020-01-15 07:20:27
问题 My neo4j db is in a corrupted state. A former node, also a Person node connected to a State via Address, prevents any matches from working: match (p:Person)--(:Address)--(s:State) where s.name="Cali" return p, s Node with id 101005 Neo.ClientError.Statement.EntityNotFound I suspect this is something to do with the 101005 node still existing in the label index even though it's been deleted. How do I recover without clearing all of the data? I've deleted all of the Person relationships/nodes

Cypher: Finding movies that haven't been rated yet by particular user

。_饼干妹妹 提交于 2020-01-15 03:56:07
问题 Let's say I have 3 movies in my Neo4J database: CREATE (interpreter:Movie {title: 'The Interpreter', year : 2005}) CREATE (dogville:Movie {title: 'Dogville', year : 2003}) CREATE (railwayMan:Movie {title: 'The Railway Man', year : 2013}) Also there are users: CREATE (maciej:Person {name: 'Maciej Ziarko', birthYear: 1989}) who rate movies: CREATE (maciej)-[:RATED {stars : 4, comment : "I liked that movie!" }]->(interpreter); It's easy to find movies rated by particular user using Cypher MATCH

Load Spark RDD to Neo4j in Python

这一生的挚爱 提交于 2020-01-13 07:05:49
问题 I am working on a project where I am using Spark for Data processing. My data is now processed and I need to load the data into Neo4j . After loading into Neo4j, I will be using that to showcase the results. I wanted all the implementation to de done in Python Programming. But I could't find any library or example on net. Can you please help with links or the libraries or any example. My RDD is a PairedRDD. And in every tuple, I have to create a relationship. PairedRDD Key Value Jack [a,b,c]

Create nodes and relations conditionally when loading nodes from csv in Neo4j

大城市里の小女人 提交于 2020-01-13 03:38:27
问题 I have a data set in csv format. One of the fields is a type, like an enumeration. Based on this type I need to create different types nodes and relations when loading the data using csv load. You could call a row in the csv for a super type having an attribute defining its subtype. I'm not really able to figure out how this can be done in cypher. Is my only option to split the one csv file into a csv file per type and run different cyphers ? 回答1: This document on conditional statements helps