现有 Cassandra Keyspaces 的 JanusGraph 自定义字符串顶点 ID

问题描述 投票:0回答:1

我正在尝试 JanusGraph 中的自定义顶点 ID 功能,如以下文档中所述

https://docs.janusgraph.org/master/advanced-topics/custom-vertex-id/

我使用 Cassandra 作为 JanusGraph 数据库的后端存储,并使用以下属性来启用 Janus Graph 中的自定义顶点 Id 功能,目前我正在使用带有 Java 代码的嵌入式 JanusGraph。

storage.cql.keyspace=janusgraph
graph.set-vertex-id=true
graph.allow-custom-vid-types=true

当我尝试使用现有记录已存在的现有键空间时,我收到以下异常

Exception in thread "main" java.lang.UnsupportedOperationException: Vertex does not support user supplied identifiers
    at org.apache.tinkerpop.gremlin.structure.Vertex$Exceptions.userSuppliedIdsNotSupported(Vertex.java:163)
    at org.janusgraph.graphdb.tinkerpop.JanusGraphBlueprintsTransaction.addVertex(JanusGraphBlueprintsTransaction.java:119)
    at org.janusgraph.graphdb.tinkerpop.JanusGraphBlueprintsGraph.addVertex(JanusGraphBlueprintsGraph.java:143)

但是,一旦我在新的 Cassandra Key 空间上尝试相同的代码,它就会按预期工作,并且能够使用下面的代码存储字符串自定义顶点 ID

 Vertex firstVertex = g.addV("record")
                       .property(T.id,"customVertexId1")
                       .property("recordId", "abc")
                       .next();

所以我的疑问是这个自定义顶点 ID 不能应用于现有的键空间?我们总是需要创建新的键空间才能在 JanusGraph 中使用自定义字符串类型 vertexId?请推荐

graph-databases janusgraph
1个回答
0
投票

参见 https://docs.janusgraph.org/advanced-topics/custom-vertex-id/#alter-an-existing-graph

基本上,如果您想在现有图表上使用它,您应该这样做

mgmt = graph.openManagement();
mgmt.set("graph.set-vertex-id", true);
// optional, if you want to provide string ID
mgmt.set("graph.allow-custom-vid-types", true);
mgmt.commit();
© www.soinside.com 2019 - 2024. All rights reserved.