cypher

Cypher query to find nodes that are not related to other node by property

拈花ヽ惹草 提交于 2019-12-24 16:53:16
问题 Consider the following DB structure: For your convenience, you can create it using: create (p1:Person {name: "p1"}),(p2:Person {name: "p2"}),(p3:Person {name: "p3"}),(e1:Expertise {title: "Exp1"}),(e2:Expertise {title: "Exp2"}),(e3:Expertise {title: "Exp3"}),(p1)-[r1:Expert]->(e1),(p1)-[r2:Expert]->(e2),(p2)-[r3:Expert]->(e2),(p3)-[r4:Expert]->(e3),(p2)-[r5:Expert]->(e3) I want to be able to find all Person nodes that are not related to a specific Expertise node, e.g. "Exp2" I tried MATCH (p

How to handle NotFoundException elegantly in Neo4j 2.0?

不想你离开。 提交于 2019-12-24 15:54:30
问题 We were wishfully thinking that with Neo4j 2.0, concurrently querying and deleting nodes will no longer throw NotFoundException. Our previous system using Neo4j 1.9.3 was full of checks to handle this exception(very ugly code). Is there any better way to handle NotFoundException(if not eliminate) in neo4j 2.0 or, in the pipeline? Stack Trace: org.neo4j.graphdb.NotFoundException: Node 2432 not found at org.neo4j.kernel.impl.core.NodeManager.getNodeForProxy(NodeManager.java:425) at org.neo4j

Delete several nodes in Neo4j

亡梦爱人 提交于 2019-12-24 14:42:55
问题 I have an array of multiple IDs of nodes to delete. Every Cypher example I can find either deletes one node or all nodes. How would one delete nodes that match an array of IDs, in a single query? Something like this... (pseudocode) : MATCH (n:Node) WHERE (n.id in ['id_a', 'id_b']) DELETE n; 回答1: You can use the IN list operator: If id is a property: WITH [1,2,3,4] AS ids MATCH (n) WHERE n.id IN ids DETACH DELETE n; If by id you mean the internal node id: WITH [1,2,3,4] AS ids MATCH (n) WHERE

cypher PROFILE via neo4j REST API

孤街醉人 提交于 2019-12-24 14:28:35
问题 Can anyone tell me how to run a PROFILE'd query using teh neo4j REST API such as PROFILE MATCH (n:LABEL) return n; When I run this either in Java using the RestCypherQueryEngine or the even using a raw HTTP post directly I get message: "Invalid input 'P': expected SingleStatement (line 1, column 1) "PROFILE MATCH (n:LABEL) return n;" ^" exception: "SyntaxException" I though I had read somewhere that this is possible not only through the server console 回答1: The old cypher endpoint (i.e /db

Neo4j manual/explicit indexes and non-string range queries

时光总嘲笑我的痴心妄想 提交于 2019-12-24 14:06:12
问题 I was able to port my Neo4j 3.4.0 application to use manual indexes and APOC procedures instead of queries over the indexles relationship properties. Everything is working like a charm except one last thing - I ran into the issue with non-string Lucene range queries. They are not working as expected Lucene query language and numeric range For example: I'm applying the following Lucene query predicate in order to get all inclusive numbers in 2 to 6 range: value:[2 TO 6] and receive the

neo4j partial dump with cypher in java

你。 提交于 2019-12-24 13:38:36
问题 Yesterday i asked a question but it was unclear, so i created a new one with really better explanations to find the answer i need :). So, in my Java Application, i need to do a neo4j copy System, here is an example: A <--- this is a project / \ <--- With relationships B C <--- and subnodes + Labels / \ / \ <--- with a depth unknown ......... I need to do a copy of this in my database, with another id, like this: A A1 / \ / \ B C B1 C1 / \ / \ / \ / \ ......... .......... In neo4j shell, i can

neo4j - Issue converting gremlin query to cypher

一个人想着一个人 提交于 2019-12-24 13:26:39
问题 I've been using NEO4j database for a recent project at work. Recently, we noticed that Cypher queries run faster than Gremlin so we decided to convert our queries. We are running the queries using the .Net graph client. There is one Gremlin query that I'm having trouble converting to Cypher. ----Gremlin(this works and produces a result of Node(CustomerNode)....should be brackets around CustomerNode but the editor won't take it) var results2 = graphClient.RootNode .Out<ApplicationNode>(

Set label from a nodes property

会有一股神秘感。 提交于 2019-12-24 12:10:25
问题 How can i add a label for a node from one of the nodes properties ? I have a large CSV-file with a label in one column. With the LOAD CSV command its not possible to set a nodes label from a CSV-column value. Is there anoter way ? 回答1: The APOC procedures Neo4j plugin contains some useful procedures for helping to refactor a graph (https://neo4j-contrib.github.io/neo4j-apoc-procedures/#_graph_refactorings) For your needs, you can use the following procedure : CALL apoc.create.addLabels( node,

Is py2neo caching burning me?

与世无争的帅哥 提交于 2019-12-24 11:45:14
问题 I am running this code: c = """ match(r:XX) optional match(r)-[]-(m) with count(m) as mc, r match(x) return count(x) as all, r, mc """ (snip!) while(True): tx = remote_graph.cypher.begin() res = remote_graph.cypher.execute(c) tx.rollback() time.sleep(15) (snip!) I know for a fact the XX node's properties are changing every second - there a daemon running. However, when I run this, I always get the same values back in res but for r only - all is changing. The query isn't changing. I wonder if

How to find a path in cypher the ungreedy way

爷,独闯天下 提交于 2019-12-24 11:37:42
问题 Actually i'm modelling TEI-encoded XML-Text in a graph (words as a chain of nodes) and i want to find shortestPaths and only the very shortest path in a graph. My query looks like MATCH (w0:XmlWord)-[:NEXT*..6]->(n:XmlTag {_name:'lb'})-[:NEXT*..6]->(w1:XmlWord) RETURN id(w0), id(w1); And I need only the shortest possible path but neo4j gives me all possibilities until to the 6th step. The result should be the nodes Vorträge , über , des , and Freiherrn Neo4j gives me back all possible