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

Gremlin MergeV创建顶点正常但更新时属性错乱求助

Gremlin mergeV执行时属性错乱问题

测试mergeV查询逻辑:顶点ID不存在则创建带属性的顶点,存在则更新对应属性。清空所有顶点后首次运行可成功创建3个属性正确的顶点,但再次运行修改了v-2的email值(改为person-22@example.org)的相同查询时,出现属性错乱异常:返回结果中v-1的email变成了person-22@example.org,v-2和v-3的email均为person-3@example.org。

相关查询语句

g.mergeV([(T.id):'v-1']).
    option(onCreate, [(T.label): 'Person', 'email': 'person-1@example.org', 'age': {age}]).option(onMatch, sideEffect(property(single, 'email', 'person-1@example.org')).sideEffect(property(single, 'age', {age})).constant([:])).
  mergeV([(T.id):'v-2']).
    option(onCreate, [(T.label): 'Person', 'email': 'person-22@example.org', 'age': {age}]).option(onMatch, sideEffect(property(single, 'email', 'person-22@example.org')).sideEffect(property(single, 'age', {age})).constant([:])).
  mergeV([(T.id):'v-3']).
    option(onCreate, [(T.label): 'Person', 'email': 'person-3@example.org', 'age': {age}]).option(onMatch, sideEffect(property(single, 'email', 'person-3@example.org')).sideEffect(property(single, 'age', {age})).constant([:])).
    id()

异常返回结果

{
  "requestId": "7fd4de9f-8c25-4493-98f7-a39c0292edc5",
  "status": {
    "message": "",
    "code": 200,
    "attributes": {
      "@type": "g:Map",
      "@value": []
    }
  },
  "result": {
    "data": {
      "@type": "g:List",
      "@value": [
        {
          "@type": "g:Vertex",
          "@value": {
            "id": "v-1",
            "label": "Person",
            "properties": {
              "age": [
                {
                  "@type": "g:VertexProperty",
                  "@value": {
                    "id": {
                      "@type": "g:Int32",
                      "@value": 92892634
                    },
                    "value": {
                      "@type": "g:Int32",
                      "@value": 30
                    },
                    "label": "age"
                  }
                }
              ],
              "email": [
                {
                  "@type": "g:VertexProperty",
                  "@value": {
                    "id": {
                      "@type": "g:Int32",
                      "@value": -928922435
                    },
                    "value": "person-22@example.org",
                    "label": "email"
                  }
                }
              ]
            }
          }
        },
        {
          "@type": "g:Vertex",
          "@value": {
            "id": "v-2",
            "label": "Person",
            "properties": {
              "age": [
                {
                  "@type": "g:VertexProperty",
                  "@value": {
                    "id": {
                      "@type": "g:Int32",
                      "@value": 92892635
                    },
                    "value": {
                      "@type": "g:Int32",
                      "@value": 30
                    },
                    "label": "age"
                  }
                }
              ],
              "email": [
                {
                  "@type": "g:VertexProperty",
                  "@value": {
                    "id": {
                      "@type": "g:Int32",
                      "@value": -1319118437
                    },
                    "value": "person-3@example.org",
                    "label": "email"
                  }
                }
              ]
            }
          }
        },
        {
          "@type": "g:Vertex",
          "@value": {
            "id": "v-3",
            "label": "Person",
            "properties": {
              "age": [
                {
                  "@type": "g:VertexProperty",
                  "@value": {
                    "id": {
                      "@type": "g:Int32",
                      "@value": 92892636
                    },
                    "value": {
                      "@type": "g:Int32",
                      "@value": 30
                    },
                    "label": "age"
                  }
                }
              ],
              "email": [
                {
                  "@type": "g:VertexProperty",
                  "@value": {
                    "id": {
                      "@type": "g:Int32",
                      "@value": -1319118436
                    },
                    "value": "person-3@example.org",
                    "label": "email"
                  }
                }
              ]
            }
          }
        }
      ]
    },
    "meta": {
      "@type": "g:Map",
      "@value": []
    }
  }
}

内容的提问来源于stack exchange,提问作者Péricles Serotini

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.02 10:33:28