logo
down
shadow

Query case-specific nodes in neo4j


Query case-specific nodes in neo4j

By : user2954810
Date : November 22 2020, 10:33 AM
this will help As mentionned in the question comment, your calculation should be reversed :
code :
node j - node i >= 2
MATCH (n:Case) 
MATCH path=(pe)<--(n)-->(pe2)
WHERE pe.name = pe2.name
AND pe2.id - pe.id >= 2
WITH path,n, (pe2.id - pe.id) as length
WITH range(head(nodes(path)).id+1, last(nodes(path)).id-1) as ids,
     n, 
     head(nodes(path)).id as starter,
     length
UNWIND ids as x
MATCH (perf:Performer {id:starter})<--(n)-->(perf2:Performer {id:x})
MERGE (perf)-[:RELATES_TO {value:1, length:length}]->(perf2)


Share : facebook icon twitter icon
Neo4j cypher query to get all nodes without a relationship to specific other node

Neo4j cypher query to get all nodes without a relationship to specific other node


By : Mathieu
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I use Neo4j 2.3.1 and looking I am looking for a cypher query which gives me all nodes in the database which are not connected to the specific other node. My Tree looks like this: , This should work:
code :
MATCH (red)<-[*]-(parent)-[*0..10]->(children)
WHERE red.id = xxx
RETURN parent, children
Neo4j Cypher Query to get all sub nodes until reaching a node with a specific relationship

Neo4j Cypher Query to get all sub nodes until reaching a node with a specific relationship


By : Anant Kashyap
Date : March 29 2020, 07:55 AM
will be helpful for those in need Does this query work for you?
It should return each Blue node (that has a path to any Red nodes) and its "sub-nodes" (along each of those paths), ignoring paths in which any sub-node (except the first) has an incoming ANALYTICALLY_COMPOSED relationship:
code :
MATCH (a:Blue)-[:ANALYTICALLY_COMPOSED]->(b)
MATCH p=(b)-[rels*]-(:Red)
WITH a, NODES(p) AS subnodes
WHERE NONE(n IN subnodes[1..] WHERE ()-[:ANALYTICALLY_COMPOSED]->(n)) 
RETURN a, subnodes;
Complex neo4j cypher query to traverse a graph and extract nodes of a specific label and use them in optional match

Complex neo4j cypher query to traverse a graph and extract nodes of a specific label and use them in optional match


By : Avani Nagar
Date : March 29 2020, 07:55 AM
Any of those help Use filter notation instead of extract and you can drop any nodes that aren't labelled right. Try out this query instead:
code :
MATCH p = (ph:Phone {Phone_ID : "3851308.0"}) - [:Customer_Send|:Customer_used_ID|:Customer_used_Phone*1..5] - ()
WITH ph, [node IN NODES(p) WHERE node:Customer] AS customer_nodes
UNWIND customer_nodes AS c_node
OPTIONAL MATCH (c_node) - [r1:Customer_at_Agent] - ()
RETURN ph, COLLECT(DISTINCT r1)
Neo4j: Query for a path between two nodes in a specific order of relationships and knowing only label of the last node

Neo4j: Query for a path between two nodes in a specific order of relationships and knowing only label of the last node


By : Joetta Sanders
Date : March 29 2020, 07:55 AM
it fixes the issue For using APOC path expander, provided you're using one of the APOC releases from Winter 2018 or newer, you can take advantage of the new sequences feature, which lets you define a repeating sequence of node labels and relationship types. In this case we'll limit the repetition with the maxLevel config parameter.
code :
MATCH (start:N1{id:'xyz'})
CALL apoc.path.expandConfig(start, {sequence:'N1, a>, N2, b>, N3, c>, N4', maxLevel:3}) YIELD path
RETURN path
ORDER BY length(path) DESC
LIMIT 1
Writing a query in Neo4j for finding specific relations between nodes

Writing a query in Neo4j for finding specific relations between nodes


By : samseattle05
Date : March 29 2020, 07:55 AM
With these it helps Let's fix up the first part of your query first, then look at the rest.
You're doing some redundant matching here, it's best to set a variable for Aviv's node so you can reuse it in the rest of your query.
code :
MATCH (a)-[:watched]->(m:Movie), (a)-[:liked]->(m) 
WITH a, collect(m) as movies

MATCH (a:Person{name:'Aviv'})-[:friend*1..3]-(f:Person) 
WHERE a <> f // faster way to ensure Aviv isn't included
WITH distinct f, movies  // deduplicate

MATCH (f)-[:watched|liked]->(m)
WHERE m in movies
WITH m, count(distinct f) as friendWatchedOrLikedCount
WHERE friendWatchedOrLikedCount = 2
RETURN m
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org