Hi everybody,

My issue is the following, I have a Neo4j database containing info about 
different objects and their relations. I am running the query from a JAVA 
API
I generate automatically the query by matching the nodes one by one and the 
relations between them.

The query has the following shape:

MATCH (Painting_1:Piece)
MATCH (Blue_2:Surface)
MATCH (Red_0:Surface)
MATCH (Blue_3:Surface)
MATCH (Red_1:Surface)
MATCH (Painting_2:Piece)
MATCH (Blue_6:Surface)
MATCH (Red_4:Surface)
MATCH (Blue_7:Surface)
MATCH (Red_5:Surface)
WHERE Blue_2.name CONTAINS 'Sea'
AND Red_0.name CONTAINS 'Cherry'
AND Blue_3.name CONTAINS 'Sea'
AND Red_1.name CONTAINS 'Cherry'
AND Blue_6.name CONTAINS 'Sea'
AND Red_4.name CONTAINS 'Cherry'
AND Blue_7.name CONTAINS 'Sea'
AND Red_5.name CONTAINS 'Cherry'
AND (Painting_1)-[:SAME_HALL]->(Painting_2)
AND (Blue_2)-[:PAINTED_WITH]->(Painting_1)
AND (Red_0)-[:PAINTED_WITH]->(Painting_1)
AND (Blue_3)-[:PAINTED_WITH]->(Painting_1)
AND (Red_1)-[:PAINTED_WITH]->(Painting_1)
AND (Blue_6)-[:PAINTED_WITH]->(Painting_2)
AND (Red_4)-[:PAINTED_WITH]->(Painting_2)
AND (Blue_7)-[:PAINTED_WITH]->(Painting_2)
AND (Red_5)-[:PAINTED_WITH]->(Painting_2)
RETURN Painting_1.name,
Painting_2.name

So I construct the graph by loading all the condition one by one. Probably 
this is not the best but I don't know how to improve it.

The thing is that this query works but as soon as the subgraph I am 
querying for is small. When the subgraph grows the times for responding the 
query become huge. Maybe there is another way to query for a particular 
subgraph in the DB? Or maybe the fact of having so many restrictions will 
only have this problem.

Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to