문제

Are auto-indices on (node or relationship) properties used by the Cypher execution engine when executing a filtering WHERE clause? If not, is there a way to tell Cypher to use them? What about for third-party (e.g., Lucene) indices?

도움이 되었습니까?

해결책

This is something that we've thought a lot about, but alas, not yet.

The indexing part of Neo4j is going to get an overhaul soon, and when that happens, we will tie Cypher closer to it, to be able to do this, and other interesting things (like heuristics to pick the right index to use).

You can do it manually though. If you have a movies<-[:ACTS_IN]-actor model, and you want all actor named Kevin Bacon that have participated in a movie, you can write it as:

START movie=node:movies("title:M*") 
MATCH movie<-[:ACTS_IN]-actor
WHERE actor.name = "Kevin Bacon"
RETURN movie.title

or, you can do the same with indexes:

START movie=node:movies("title:M*"),
      actor=node:actors(name="Kevin Bacon")
MATCH movie<-[:ACTS_IN]-actor
RETURN movie.title

Which one is the fastest is hard to tell. Depends.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top