1
votes

Ok, let me set this up: I have created a Neo4J Database with every vehicle trim in north America as a Vehicle Node (Every vehicle node has a :Vehicle label). Now, I have also created 22 other labeled nodes to describe a feature. For example, I have a ":MDL" feature node, a ":YR" feature node, and a ":DRIVE" feature node, and a ":DIV" feature node. Each of the feature nodes have a property called "value".

So, If I want to find all 2016 Chevrolet Models that have 4WD, my Cypher query would be as follows :

MATCH
    (v:Vehicle)--(:DIV{value:"Chevrolet"}),
    (v)--(:DRIVE{value:"4WD"}),
    (v)--(:YR{value:"2016"}),
    (v)--(model:MDL)
return distinct(model.value)

And, this successfully returns the 8 Chevy models that offer 4WD (as opposed to AWD) as follows:

"Silverado 3500HD"
"Colorado"
"Silverado 2500HD"
"Silverado 1500"
"Silverado 3500HD Chassis"
"Tahoe"
"Suburban"
"Suburban 3500HD"

My question, is looking at the profile plan, I don't think this is the most efficient way. Because basically Cypher is making each match pattern independently, and then merging the results. I am trying to get Cypher to do this all in one step. Does anyone have any recomendations on how to make this more efficient?

1

1 Answers

1
votes

What about

MATCH (v:Vehicle)--(model:MDL)
WHERE (v)--(:DIV{value:"Chevrolet"})
AND (v)--(:DRIVE{value:"4WD"})
AND (v)--(:YR{value:"2016"})
RETURN DISTINCT (model.value)

not sure that'll change the profile a whole lot, but it does seem to express better what you are trying to accomplish.

Hope this helps !

Regards, Tom