问题
After reading through Traversal API, I liked the idea the concept of BranchSelector
, Expander
and Uniqueness
. It is something like describing how traversal should be made. In other words, I felt it like giving declarative description of traversal to be performed. The fluent API is well suited for this purpose. However it seems that it can only be used to target neo4j whose database can be accessed through file system, that is we need to specify graph.db
folder path. This essentially means we can only use it in embedded mode. Can we use traversal API to perform traversal on graph running on remote machine?
Especially I want to have the convenience of API (BranchSelector
, Expander
and Uniqueness
) available to perform traversal.
I read we can use bolt to access embedded neo4j. However this does not seem to mean that we can use embedded neo4j from remote machine.
So it seems that their is no way to use Traversal API if I cannot have access to physical (or directory) location of graph database. Is it so?
回答1:
The Traversal API can only be used if the code is colocated with the data, otherwise it would usually be awfully slow. The problem is that it's not purely declarative, since you can provide implementations of PathExpander
, Evaluator
, etc. instead of only using pre-defined constants.
However, there are several ways of having this code colocated:
- one is indeed by using Neo4j in embedded mode, as you have noted
- another one is by extending Neo4j, using either used-defined procedures / functions, or unmanaged extensions
See APOC for a collection of procedures developed by the Neo4j community, including some traversals.
来源:https://stackoverflow.com/questions/40720077/using-neo4j-traversal-api-to-perform-traversal-on-neo4j-running-on-other-machine