cypher

How to delete a node and its connected nodes with Neo4j cypher query?

我是研究僧i 提交于 2019-12-13 03:36:12
问题 For example, I want to delete Actor node with id = "005A" and its connected Movie nodes. The relationship between Actor and Movie node is ACTED_IN . I have tried this cypher query: MATCH (a:Actor {id: "005A"}) OPTIONAL MATCH (a)-[r:ACTED_IN]->(m) DELETE a, r, m; but it didn't work, I got TransactionFailureException: Unable to commit transaction error. Anyone can give a solution? UPDATE: I found out that there is relationship from other node ( Agency ) to Actor node which labeled as OWNED . So

Neo4j / Cypher: Match nodes only if they have a relation with 1 or more other nodes

戏子无情 提交于 2019-12-13 03:32:21
问题 I'm having some trouble on this query I am trying to build. I have looked plenty of places over the internet and I couldn't seem to find an answer, so I am asking here. so here is what my schema somewhat looks like. (sorry for shitty paint diagram) The query I want is; Starting from one Route node, I get multiple RS, and a single OMS from each RS I want to find all Route nodes which eventually connects to the same (or more) OMS nodes here is my current query: MATCH (st)--(rs:RS)--(oms:OMS)

optimize cypher query fired from python

帅比萌擦擦* 提交于 2019-12-13 03:31:52
问题 driver for neo4j for python . I have a program that dynamically creates around 10-12 queries . The final result from all queries is collected in a list` and returned. Below are 10 such queries: MATCH (sslc:subSubLocality)-[:CHILD_OF]->(v4)-[:CHILD_OF]->(v3)-[:CHILD_OF]->(v2)-[:CHILD_OF]->(st:state) WHERE (st.name_wr = 'abcState') AND (sslc.name_wr= 'xyzSLC' OR sslc.name_wr= 'abcxyzcolony') RETURN st, sslc, v4, v3, v2 MATCH (slc:subLocality)-[:CHILD_OF]->(v3)-[:CHILD_OF]->(v2)-[:CHILD_OF]->(st

Finding cypher paths that don't visit the same node twice

自作多情 提交于 2019-12-13 03:03:44
问题 I'm looking for the paths between two nodes in a graph, but my graph has a loop in it and so I'm getting paths back that are undesirable. I'm hoping that someone here can help me think out a sensible remedy. Here's my graph: A | 2 | C-3-D | | | 4 5 | | E | | | 6 | | F-7-G The letters are nodes, and the numbers are edges (relationships). CREATE (a {i: "A"}) CREATE (c {i: "C"}) CREATE (d {i: "D"}) CREATE (e {i: "E"}) CREATE (f {i: "F"}) CREATE (g {i: "G"}) CREATE a-[:r {i:2}]->c-[:r {i:3}]->d-[

Boolean value return from Neo4j cypher query without CASE

孤街醉人 提交于 2019-12-13 02:59:26
问题 I know that you can do this match (user:User {username:'${username}', password:'${password}'}) RETURN CASE WHEN user.blocked='true' THEN true ELSE false END as blocked, user.username as username, user.uid as uid But I hope to find a shorter way to return booleans with cypher, I am using nodejs and having CASE like this on every boolean props my objects have seems very verbose... Is there a better way ? thanks 回答1: You can replace this: CASE WHEN user.blocked='true' THEN true ELSE false END AS

Building a complex output and ranking the records in Neo4j

北城以北 提交于 2019-12-13 02:43:12
问题 This issue is directly related to the previous post: How to calculate rank for float values in Neo4j? I am trying to merge the "rank" and "weight" values with origin and path. I could successfully do this for origin: CALL apoc.load.json("file:///.../input.json") YIELD value UNWIND value.origin AS orig MATCH(origin:concept{name:orig.label}) WITH value, collect(origin) as origins UNWIND value.target AS tar MATCH(target:concept{name:tar.label}) UNWIND origins AS origin WITH origin, target CALL

Neo4j: fulltext indices and auto indexing in Cypher

孤街浪徒 提交于 2019-12-13 02:39:38
问题 I'm currently struggeling with fulltext indices and auto indexing in Cypher. I'm using Java embedded, Neo4j v 1.8.2. My basic question is: How can fulltext indices be queried with Cypher? When I create the following index: Index<Node> fulltextIndex = index.forNodes( "fulltextIndex", MapUtil.stringMap( IndexManager.PROVIDER, "lucene", "type", "fulltext" ) ); The following Cypher statement does not return anything: START n=node:fulltextIndex(name='*er*') RETURN n; The following piece of java

Neo4j, REST API, java - cypher queries

允我心安 提交于 2019-12-13 02:14:15
问题 I learn REST API with Java and tried run this simple code, but I got error. Something wrong with this part of code: RestAPI graphDb = new RestAPI.... I use this external JAR (http://m2.neo4j.org/content/repositories/releases/org/neo4j/neo4j-rest-graphdb/2.0.0/neo4j-rest-graphdb-2.0.0.jar) import java.util.Collections; import java.util.Iterator; import java.util.Map; import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.rest.graphdb.RestAPI; import org.neo4j.rest.graphdb

Filtering on node property in long distance path

本秂侑毒 提交于 2019-12-13 02:05:26
问题 Starting from an item recommended by people, is there a way to filter on a person property, such as age, while traversing at long distance friendship relationships? For instance in the following cypher query, I'd like to only traverse nodes of person +18y, not just filtering on p's age. MATCH path = (:Fruit {Name: 'Apple'}) <-[:LIKES]- (:Person) -[:FRIENDOF*1..5]- (p:Person) -[:LIKES]-> (:Device {Name: 'iPhone'}) return path UPDATE more details : In this exemple the graph contains molecules

How to add infinity, NaN, or null values to a double[] property on a node in Cypher/Neo4j

独自空忆成欢 提交于 2019-12-13 00:41:55
问题 I have some nodes in my neo4j graph that are a combination of multiple entities. On these nodes I have a property named "p_value" that has a type of double[]. I'm merging new entities into existing nodes and with my merge command I'm using on match to push the new p_values onto the end of this double[] array. The issues is that for some of my entities I don't have p_values, so I need to push something like -infinity/infinity, NaN, or NULL into my double[] p_value array. Here is an example