I have a Cypher query that is performing extremely poorly (~ 30 sec):
START foo=node:foos('Name:*')
MATCH foo<-[:HasMember]-()<-[:PartOf]-()<-[:Connected]-bar
WHERE foo.Name IN ["name1", "name2"] AND bar.Enabled = true
RETURN DISTINCT bar.Guid AS Guid, foo.Name AS Name
What I think what is happening is that the Lucene index is used to pull out all values, and then graph search is used to match to the names in the set, because if I change the query to the one below it is orders of magnitude faster (16 ms):
START foo=node:foos('Name:"name1" OR Name:"name2"')
MATCH foo<-[:HasMember]-()<-[:PartOf]-()<-[:Connected]-bar
WHERE bar.Enabled = true
RETURN DISTINCT bar.Guid AS Guid, foo.Name AS Name
Is there a way to get the first query to execute as fast as the second without resorting to manually building a Lucene query out of the name set?
The other option would be to use a traversal but I prefer to stay in Cypher-land if possible.