cancel
Showing results for 
Search instead for 
Did you mean: 

Error after running heavy query

andy_hegedus
Graph Voyager

Hi,

Running this query:

 

 

 

Match (n:company)<-[:Assigned_to]-(a:patent)-[r:Cites]->(d:patent)-[:Assigned_to]->(n)
where exists {(a)-[:Cites*2..4]->(d)}
set r.inherited =true

 

 

Which is known to be heavy.  After several hours of running, I got this error message.

I am running from within Neo4J Desktop to a local database.

andy_hegedus_0-1655302358863.png

 

Any advice on remediation and also how to make the very faster would be welcome.

Andy

3 REPLIES 3

Depending on your data volume you might need to batch it. And use shortestPath in your check.

I think a better version is:

 

 

Match (n:company)
call { with n
match (n)<-[:Assigned_to]-(a:patent)-[r:Cites]->(d:patent)-[:Assigned_to]->(n)
where not shortestPath((a)-[:Cites*..4]->(d)) is null
set r.inherited =true
} in transactions of 1000 rows

 

 

andy_hegedus
Graph Voyager

Hi Michael,

Thank you for your reply. For your solution I found that I had to include :auto to avoid an error.

:auto Match (n:company)
call { with n
match (n)<-[:Assigned_to]-(a:patent)-[r:Cites]->(d:patent)-[:Assigned_to]->(n)
where not shortestPath((a)-[:Cites*..4]->(d)) is null
set r.inherited =true
} in transactions of 1000 rows

 But also I am not sure the logic is quite in line with what I want to accomplish.

The goal of the query was to identify relationships to grandparents, great grandparent,  and great, great grandparents and define them as inherited. So from a shortest path perspective the question becomes if  always have a path length of 1 by definition of the initial match statement, but if another path exists then set that initial path to inherited=true.

As an example I have this snippet from my graph, Starting at the node on left, I can reach all of the other nodes directly but I would like to tag the highlighted relationships as inherited.  There is a business meaning for this I want to capture. The code you suggested sets them all to inherited which is not the intent. With that in mind, how could I exploit shortestPath? I am almost asking if there is at least one next longer path and if so the original relationship, (a)-[r:Cites]]->(d) r.inherited can be set to true.  So the search process does need to find all just at least 1 longer.

andy_hegedus_0-1655405832339.png

Andy

andy_hegedus
Graph Voyager

A bit more info.

I ran my original query in batch transaction mode with

 

:auto Match (n:company)
call{ with n
Match (n)<-[:Assigned_to]-(a:patent)-[r:Cites]->(d:patent)-[:Assigned_to]->(n)
where exists {(a)-[:Cites*2..4]->(d)}
set r.inherited =true}
in transactions of 1000 rows

 

And got a similar error message:

WebSocket connection failure. Due to security constraints in your web browser, the reason for the failure is not available to this Neo4j Driver. Please use your browsers development console to determine the root cause of the failure. Common reasons include the database being unavailable, using the wrong connection URL or temporary network problems. If you have enabled encryption, ensure your browser is configured to trust the certificate Neo4j is configured to use. WebSocket `readyState` is: 3

This occurred after ~1 hr or processing.  Also upon inspection no relationships got set with the inherited property. I know that there exists such cases and my original query without the :auto and in transactions was successful in setting the property.

 Andy