Neo4j – Java heap space Wrong query or setting?

I have neo4j a problem

introduce

I have to build an application that stores bus / train routes This is my architecture:

Node:

>Organization: companies with routes / buses, etc. > Route: bus route, e.g. Paris – Berlin. > Vehicle (in this case, bus): fisical bus with unique license plate. > Stop: points to a map with latitude and longitude

Important relationships:

>Next: This is a very important relationship

The next relationship contains the following attributes:

>Starthour > startminutes > endhour > endminutes > DayOfWeek (from 0 to 6 – sun, Monday, etc.) > vehicleid

problem

My query is:

MATCH (s1:Stop {id: {departureStopId}}),(s2:Stop {id: {arrivalStopId}})
OPTIONAL MATCH (s1)-[nexts:NEXT*]->(s2)
WHERE ALL(i in nexts WHERE toInt(i.dayOfWeek) = {dayOfWeek} AND toInt(i.startHour) >= {hour})
RETURN nexts
LIMIT 10

For example, I want to find all nexts relationships, where DayOfWeek is Sunday (0) and the attribute starthour > 11

After that, I usually parse and validate the final object on my nodejs backend

This works at the beginning of my relationship with 1K Now I have a 10k relationship. My query has a timeout problem or the query is solved in 30s Too much time... I don't know how to solve this problem I use neo4j and docker. I try to read the setup documentation, but I don't know how Java works

Can you help us?

UPDATE

Thank you! Now I've solved it with "allshortestpaths", but I think I'll rename all the relationships (as Michael hunger said)

Solution

Have you ever tried:

MATCH p=allShortestPaths((s1:Stop {id: {departureStopId}})-[:NEXT*]-> (s2:Stop {id: {arrivalStopId}}) )
WHERE ALL(i in RELS(p) WHERE toInt(i.dayOfWeek) = {dayOfWeek} AND toInt(i.startHour) >= {hour})
RETURN rels(p) as nexts
LIMIT 10

This should use the fast shortest path algorithm because:

For more information, see https://neo4j.com/docs/developer-manual/current/cypher/execution-plans/shortestpath-planning/#_shortest_path_with_fast_algorithm.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>