我使用自定义分区和集群键创建了以下架构:
schema.propertyKey('_partition').Text().create()
schema.propertyKey('topic_id').Uuid().create()
schema.vertexLabel('custom_topic')
.partitionKey('_partition').clusteringKey('topic_id').create()
我现在可以使用 gremlin 通过以下方式创建顶点:
graph.addVertex(label, 'custom_topic', '_partition', 'my_partition', 'topic_id', '60bcae02-f6e5-11e5-9ce9-5e5517507c66')
但是,我们的应用程序是使用 aiogremlinin 用 python 编写的,而 gremlin-python 不提供这个图形接口。我们可以使用遍历来添加顶点:
g.addV(label, 'custom_topic', '_partition', 'x', 'topic_id', '60bcae02-f6e5-11e5-9ce9-5e5517507c66')
以上作品在DSE工作室工作。但是,使用 gremlin-python 它不起作用,返回以下错误:
aiogremlin.exception.GremlinServerError: 500: 599: Could not locate method: GraphTraversalSource.addV([label, custom_topic, _partition, x, topic_id, 60bcae02-f6e5-11e5-9ce9-5e5517507c66])
DSE 报告DeserialisationError
。我尝试通过properties
几种不同的方式传递密钥:
g.addV('custom_topic').properties('_partition', 'x', 'topic_id', '60bcae02-f6e5-11e5-9ce9-5e5517507c66')
GremlinServerError: 500: 599: Vertices with custom IDs must have their IDs specified on creation.
g.addV('custom_topic').property(T.id, ['_partition', 'x', 'topic_id', '60bcae02-f6e5-11e5-9ce9-5e5517507c66'])
GremlinServerError: 500: 500: Vertex does not support user supplied identifiers
我应该如何传递这些 ID?
在发布这个问题后,我发现了允许它工作的魔法咒语。关键是在单独的调用中指定每个属性:
g.addV('custom_topic').property('_partition', 'x').property('custom_topic', '60bcae02-f6e5-11e5-9ce9-5e5517507c66')
我不知道为什么properties
不起作用,但它就在那里。