如何为远程GraphTraversalSource创建Vertex Index
问题
如何使用traversal().withRemote("conf/remote-graph.properties")创建顶点索引(Vertex Indexes)?
具体疑问
- 是否必须创建
org.apache.tinkerpop.gremlin.structure.Graph实例?Graph graph = TinkerGraph.open(configuration); - 若是,JanusGraph所需的配置在哪里获取?
对比OrientDB 3.2.18 GA Community Edition搭配Orientdb-Gremlin的OrientGraph.java示例代码:Configuration configuration = new BaseConfiguration(); configuration.setProperty(OrientGraph.CONFIG_URL, orientGraph_configUrl); configuration.setProperty(OrientGraph.CONFIG_USER, orientGraph_configUser); configuration.setProperty(OrientGraph.CONFIG_PASS, orientGraph_configPass); configuration.setProperty(OrientGraph.CONFIG_TRANSACTIONAL, true); OrientGraph orientGraph = OrientGraph.open(configuration); GraphTraversalSource g = orientGraph.traversal(); - 若必须创建,如何编写可正常连接的最简
JanusGraphManagement实例代码?
调研发现
g.V().index();方法位于org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal中
有相关示例,但目前仍未完全理解该方法的用法:g.V().hasLabel("software").index() //1 g.V().hasLabel("software").values("name").fold(). order(Scope.local). index(). unfold(). order(). by(__.tail(Scope.local, 1)) //2 g.V().hasLabel("software").values("name").fold(). order(Scope.local). index(). with(WithOptions.indexer, WithOptions.list). unfold(). order(). by(__.tail(Scope.local, 1)) //3 g.V().hasLabel("person").values("name").fold(). order(Scope.local). index(). with(WithOptions.indexer, WithOptions.map) //4- Tinkergraph有
createIndex()方法,示例代码:graph = TinkerGraph.open() graph.createIndex("username",Vertex.class) - JanusGraph索引使用
JanusGraphManagement.buildIndex(String, Class)方法,但希望编写更贴近Gremlin、更通用的代码
现有代码
已知如何在Gremlin中使用空白TinkerGraph实现,但需要连接localhost:8182上已有的JanusGraph:
graph = TinkerGraph.open() g = traversal().withEmbedded(graph) g.io('data/grateful-dead.xml').read().iterate() clock(1000) {g.V().has('name','Garcia').iterate()} //// (1) graph = TinkerGraph.open() g = traversal().withEmbedded(graph) graph.createIndex('name',Vertex.class) g.io('data/grateful-dead.xml').read().iterate() clock(1000){g.V().has('name','Garcia').iterate()} //2
内容的提问来源于stack exchange,提问作者Zach
相关产品推荐
相关产品推荐

