You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Tinkerpop VertexProperty.Single基数未生效?实为valueMap输出误解

关于Gremlin中single基数顶点属性显示为数组的误解
  • 创建顶点时已明确指定VertexProperty.Cardinality.single,但曾误以为属性被存储为列表(使用Gremlin Server和Java Driver 3.7.2版本),创建代码如下:
wg.addV("label")
.property(VertexProperty.Cardinality.single,"name", "testname").next();
  • 后续发现误解源于valueMap(true)的输出特性:该方法默认会将所有字段以数组形式返回,无论顶点属性的基数是single还是list。执行以下查询:
g.V(1).valueMap(true).next();

返回结果为:

name=[peter], email=[dummy]
  • 使用by(unfold())修饰后,即可恢复单个值的正常显示:
g.V(1).valueMap(true).by(unfold()).next();

返回结果为:

name=peter, email=dummy

内容的提问来源于stack exchange,提问作者mmr25

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 11:12:34