cypher.lenient_create_relationship = true (cypher) - neo4j

How to set the cypher.lenient_create_relationship = true in neo4j.conf.
I tried to create Relationships using Cypher Query Language but it says no changes later I use OPTIONAL MATCH to forcefully connect the relationships but after I pass the OPTIONAL MATCH command it asked me to do this, how can I rectify this issue?
Here is my before and before code.
**Before
MATCH (a:Neuron), (b:Structur)
WHERE a.doi = "10.1126/science.aah511477" AND a.local_id = 1 AND b.acronym = "SSp-tr"
CREATE (a)-[r:BELONGS_TO]->(b)
after***
OPTIONAL MATCH (a:Neuron), (b:Structur)
WHERE a.doi = "10.1126/science.aah511477" AND a.local_id = 1 AND b.acronym = "SSp-tr"
CREATE (a)-[r:BELONGS_TO]->(b)
RETURN a, b, r

Related

How to filter path results based on a specific node with a specific property

enter image description here
I have a query to find the paths between two nodes. Now, I want to find any paths that have a node with a status = 'down'. However, the only query that works is to find paths without any nodes with a status of down.
Here is the query that is able to give me all the paths without a node with a status = 'down'.
MATCH path=((dev)-[r:part_of|CONNECTS*..20]-(dev2))
WHERE dev.hostname = 'fwmc0208-01' AND dev2.hostname = 'cemc0208-01.edg'
WITH nodes(path) AS n
WHERE NONE(node IN n WHERE (node.status IS NOT NULL) and node.status = 'down')
RETURN n
enter image description here
If I replace NONE with ALL, I get zero results. I've tried flipping the status to equal 'up', but this doesn't work either.
You should use the ANY function:
MATCH path=((dev)-[r:part_of|CONNECTS*..20]-(dev2))
WHERE dev.hostname = 'fwmc0208-01' AND dev2.hostname = 'cemc0208-01.edg'
WITH nodes(path) AS n
WHERE ANY(node IN n WHERE (node.status IS NOT NULL) and node.status = 'down')
RETURN n

Writing cypher query for traversing the path

I am new to Neo4j.
I am using this query to get the below layout in traversing the path in first image:
Code:
MATCH p = (r:Reports)<--(s:Schedules)<--(m:MDRMs)<--(br:Business_Requirements)-->(rp: Report_Logic)-->(ra: Reporting_layer_attributes)
where r.Report_Name ='FFIEC 031' and s.Schedule = 'RC-B - Securities' RETURN p
Blue coloured nodes are referred as Business_Requirements which have additional linked Silver coloured (Business_Attributes) nodes with relationship as MAPPED_TO.
How can I bring out the below layout through cypher query. Since the silver color nodes are not in the path, I was not able to pull the below required layout in the second image:
You can extend the MATCH by adding a second path p2, and including it in the RETURN
MATCH p = (r:Reports)<--(s:Schedules)<--(m:MDRMs)<--(br:Business_Requirements)-->(rp: Report_Logic)-->(ra: Reporting_layer_attributes),
p2 = (br)<-[:MAPPED_TO]-(ba:Business_Attributes)
where r.Report_Name ='FFIEC 031' and s.Schedule = 'RC-B - Securities'
RETURN p,p2
in case the MAPPED_TO rel is not always there, you can also use the OPTIONAL MATCH
MATCH p = (r:Reports)<--(s:Schedules)<--(m:MDRMs)<--(br:Business_Requirements)-->(rp: Report_Logic)-->(ra: Reporting_layer_attributes)
where r.Report_Name ='FFIEC 031' and s.Schedule = 'RC-B - Securities'
OPTIONAL MATCH p2 = (br)<-[MAPPED_TO]-(ba:Business_Attributes)
RETURN p,p2

How to query with two conditions in Neo4j

I am new with Neo4j and I am stucked trying to get a query with two conditions, where I want to get all the "Autors" related to "Pixar" and "Fox". So far I have tried the following two ways:
MATCH (a:Autor)- [:AUTOR_DE]-> (t:Título) -[:PRODUCIDO_POR] ->( p:Productora {Nombre: "Pixar"}),
and
MATCH (a:Autor)- [:AUTOR_DE]-> (t:Título) -[:PRODUCIDO_POR] ->( p:Productora {Nombre: "Fox"}),
return a,p
and
MATCH (a:Autor)- [:AUTOR_DE]-> (t:Título) -[:PRODUCIDO_POR] ->( p:Productora)
WHERE ( (p:Productora) = "Fox" OR (p:Productora) = "Pixar")
return a,p
Thanks in advance
Assuming that a Productora node stores its name in a name property, and that every Productora node has a unique name, this should work:
MATCH (a:Autor)-[:AUTOR_DE]->(:Título)-[:PRODUCIDO_POR]->(p:Productora)
WHERE p.name = "Fox" OR p.name = "Pixar"
WITH a, COLLECT(DISTINCT p) AS ps
WHERE SIZE(ps) = 2
return a, ps
And this should also work:
MATCH (fox:Productora), (pixar:Productora), (a:Autor)
WHERE fox.name = "Fox" AND pixar.name = "Pixar" AND
(a)-[:AUTOR_DE]->(:Título)-[:PRODUCIDO_POR]->(fox) AND
(a)-[:AUTOR_DE]->(:Título)-[:PRODUCIDO_POR]->(pixar)
return a, fox, pixar

Match nodes with two different values in same property Neo4j

I have this kind of graph:
I want to retrieve all Products that have pending or open requests. This is how Im trying
MATCH (s:ServiceRequest {srStatus: "Open"} OR {srStatus: "Pending"}) -[:FOR]->(p:Product) RETURN p
But this does not work. How can I do that?
This should work:
MATCH (s:ServiceRequest)-[:FOR]->(p:Product)
WHERE s.srStatus IN ["Open", "Pending"]
RETURN p;
and so should this:
MATCH (s:ServiceRequest)-[:FOR]->(p:Product)
WHERE s.srStatus = "Open" OR s.srStatus = "Pending"
RETURN p;

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

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}?
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

Resources