cypher

Neo4j/Cypher: Setting a map and property yields “expected valid query body”

ε祈祈猫儿з 提交于 2019-12-13 05:07:48
问题 The following query fails: MATCH n:User WHERE n.email = "test" SET n = {data}, n.created = timestamp() RETURN n Is this expected? Is it a bug? Is there a workaround? Do I have to compute the timestamp and send it along with {data} ? 回答1: A slight modification of your statement using 2 SET clauses works: MATCH n:User WHERE n.email = "test" SET n = {data} SET n.created = timestamp() RETURN n 来源: https://stackoverflow.com/questions/17686010/neo4j-cypher-setting-a-map-and-property-yields-expected

Neo4j - Cypher return 1 to 1 relationships

我的未来我决定 提交于 2019-12-13 04:46:02
问题 Using neo4j 1.9.2, I'm trying to find all nodes in my graph that have a one to one relationship to another node. Let's say I have persons in my graph and I would like to find all persons, that have exactly one friend (since 2013), and this one friend only has the other person as friend and no one else. As a return, I would like to have all these pairs of "isolated" friends. I tried the following: START n=node(*) MATCH n-[r:is_friend]-m-[s:is_friend]-n WHERE r.since >= 2013 and s.since >= 2013

Query performance when adding a new node in Neo4j

∥☆過路亽.° 提交于 2019-12-13 04:43:59
问题 I am wondering why my Cypher query is taking an exorbitant amount of time. Basically, I have a small family tree (two families), and I'm trying to add to each one a new node that carries some small bit of metadata so that the families are easier to keep isolated from each other when they are queried. (Thanks to @Tim Kuehn for this advice). Once I run the query to populate my two families, I have this, which is built quickly with no problems: Next, I want to create the aforementioned new nodes

How to return COLLECT([role, app]) using Neo4jClient?

自作多情 提交于 2019-12-13 04:41:44
问题 I have the following Cypher which I am struggling to translate into the fluent syntax: MATCH (u:User)-[:HAS_ROLE]->(r:Role)-[:ROLE_OF]->(a:App) RETURN u AS User, COLLECT([r, a]) AS Roles This is what I have so far, but I can't figure out how to return the COLLECT([r, a]) as Roles. I am using a UserDetails class to enable passing the results to a View. var results = _graphClient.Cypher .Match("(user:User)-[:HAS_ROLE]->(role:Role)-[:ROLE_OF]->(app:App)") .Return((user,role,app) => new

Neo4j breadth first search is too much slow

我的未来我决定 提交于 2019-12-13 04:41:10
问题 I need breadth first search in my database. There are 3.863 nodes, 2.830.471 properties and 1.355.783 relationships. N is my start point and m is my end point in the query but It's too much slow, so I can't get result while I started the query that is in the following segment: start n=node(42),m=node(31) match p=n-[*1..]->m return p,length(p) order by length(p) asc limit 1 How can I optimize that query? Because It must finish maximum in 20 seconds. I have 8gb ram in my own computer but I

Cypher sum property on incoming & outgoing relationships (Neo4j)

青春壹個敷衍的年華 提交于 2019-12-13 04:29:16
问题 I have multiple incoming & outgoing relationships for a node (Neo4J). Each relationship has a numeric property "weight" I need to get the difference between the incoming & outgoing weights for the node. I tried this query, but return 0 for both sums, even though sum of incoming weights is 20. MATCH out=(n:Person)-[r:FRIEND]->(), in=(n:Person)<-[s:FRIEND]-() WHERE n.personid='12345' RETURN sum(r.fweight), sum(s.fweight); Also, I tried this... and it crashes/doesnt return MATCH (n:Person)-[r

How to build Parameterized Cypher Query in Java Application Code?

不羁岁月 提交于 2019-12-13 04:15:57
问题 The idea behind parametrized queries is to re-use (cache) execution plans. If a node label or a relationship type do not vary, the execution plan would be the same at all, thus benefits can be achieved of execution plan caching. Currently, I'm my complete Cypher Query is built using Java String Building. Instead of creating the entire Cypher Query using String building I want to pass the values of the Properties as Parameter Values along with Property Names as Parameters or not. I need sample

Neo4J - Cypher: shortest path between multiple nodes

情到浓时终转凉″ 提交于 2019-12-13 04:15:32
问题 Let's say we have 4 nodes: {id:1, name:"one"} {id:2, name:"two"} {id:3, name:"three"} {id:4, name:"four"} Suppose node 1 is linked to node 2, node 2 to 3, 3 to 4 so the result would be something like: (1)-->(2)-->(3)-->(4) How would I be able to get the shortest path between multiple given nodes in any given order? A few examples: findShortestPath(2,4,3) should result in: (2)-->(3)-->(4) findShortestPath(3,1) should result in: (1)-->(2)-->(3) findShortestPath(4,1) should result in: (1)-->(2)-

'ORDER BY' results per row in cypher query(Neo4j)

时光怂恿深爱的人放手 提交于 2019-12-13 03:54:55
问题 This question is a follow on to the question here With 2 answers for that Now I need to modify this query to return those items related to this HashTag , order by createdDate (as all those items have createdDate property). I've written this query: MATCH (r:RateableEntity)<-[:TAG]-(h:HashTag:Featured) WITH h, COUNT(h) AS Count ORDER BY Count DESC SKIP 2 LIMIT 3 WITH h, Count, h.tag as Name, [(h)-[:TAG]->(m:RateableEntity {audience: 'world'}) | m][..3] AS Items UNWIND Items as row RETURN row,

JQassistant rule for TestMethods with lambda expressions and consumers asserts

蓝咒 提交于 2019-12-13 03:47:31
问题 Our project has few Unit Tests in which the asserts are passed as a lambda or consumer to the test class. Example as below. How to write a cypher rule constraint such the asserts are identified and the method is not flagged as without assert. Currently using junit4:TestMethodWithoutAssertion Test Method : @Test public void testSuccessfulIdempotency(){ transportConsumerFlow.accept(Mockito.mock(TransRequest.class), (t)->{ assertEquals(t, expectedResponseMessage); }); } In the sample above, the