Abh*_*Raj 2 gremlin titan tinkerpop3 janusgraph
我有两个问题:
如何索引这个查询?
g.V(vertexId).repeat(out().hasLabel('location')).emit().tree().next()
Run Code Online (Sandbox Code Playgroud)在 Titan 1.0 文档中,仅给出了在数据已插入时对图进行索引一次的方法。然而,在此处的generate-modern.groovy文件中
,我们看到索引是在创建顶点之前完成的,这似乎是合理的。然而,当我尝试使用时,我无法做到这一点,因为它让我失望 buildMixedIndex
非法参数异常:未知外部索引后端搜索
我的方法是
def location = mgmt.makeVertexLabel("location").make()
def displayName = mgmt.makePropertyKey("displayName").dataType(String.class).cardinality(Cardinality.SINGLE).make()
def shortName = mgmt.makePropertyKey("shortName").dataType(String.class).cardinality(Cardinality.SINGLE).make()
def description = mgmt.makePropertyKey("description").dataType(String.class).cardinality(Cardinality.SINGLE).make()
def latitude = mgmt.makePropertyKey("latitude").dataType(String.class).cardinality(Cardinality.SINGLE).make()
def longitude = mgmt.makePropertyKey("longitude").dataType(String.class).cardinality(Cardinality.SINGLE).make()
def locationByName = mgmt.buildIndex("displayNameAndShortNameAndDescriptionAndLatitudeAndLongitude", Vertex.class).addKey(displayName).addKey(shortName).addKey(description)
.addKey(latitude).addKey(longitude).indexOnly(location).buildMixedIndex('search')
Run Code Online (Sandbox Code Playgroud)
我哪里理解错了?
如果该查询花费很长时间,则问题可能是它访问了太多元素或者陷入了无限循环。现有的 JanusGraph/Titan 索引对此无济于事。您已经通过 id 进行了直接顶点查找,g.V(vertexId)并且查询的其余部分是从该顶点遍历邻域。我建议使用边缘标签,即out('friends')限制您访问的边缘数量。您还可以使用它simplePath()来消除循环路径。您还可以使用times()或until()来限制该步骤的循环次数repeat()。
您引用的配置示例仅使用复合索引,不需要索引后端。
混合索引需要配置索引后端,Elasticsearch、Lucene 或 Solr。选择其中之一,然后确保在初始化图表时传递正确的配置属性。您可以在目录中的分发 zip 文件中找到几个示例conf。例如,在 中janusgraph-cassandra-es.properties,您会发现:
index.search.backend=elasticsearch
index.search.hostname=127.0.0.1
index.search.elasticsearch.client-only=true
Run Code Online (Sandbox Code Playgroud)
其中searchinindex.X.backend是您必须传递给 的所选索引配置名称buildMixedIndex(X)。
| 归档时间: |
|
| 查看次数: |
523 次 |
| 最近记录: |