Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在gremlin中合并地图列表_Gremlin - Fatal编程技术网

在gremlin中合并地图列表

在gremlin中合并地图列表,gremlin,Gremlin,我有这样的关系: person--喜欢-->主题 这是我的疑问: g.V(). hasLabel('person'). has('name', 'Joe'). outE('likes'). range(0, 2). union(identity(), inV().hasLabel('subject')). valueMap('rating', 'name'). 此时,我得到的结果如下所示: [ { "rating": 3

我有这样的关系:

person--喜欢-->主题

这是我的疑问:

g.V().
  hasLabel('person').
  has('name', 'Joe').
  outE('likes').
  range(0, 2).
  union(identity(), inV().hasLabel('subject')).
  valueMap('rating', 'name').
此时,我得到的结果如下所示:

 [
      {
        "rating": 3.236155563
      },
      {
        "rating": 3.162886797
      },
      {
        "name": "math"
      },
      {
        "name": "history"
      }
]
 [
      {
        "rating": 3.236155563,
        "name": "math"
      },
      {
        "rating": 3.162886797,
        "name": "history"
      },
]
我想得到这样的东西:

 [
      {
        "rating": 3.236155563
      },
      {
        "rating": 3.162886797
      },
      {
        "name": "math"
      },
      {
        "name": "history"
      }
]
 [
      {
        "rating": 3.236155563,
        "name": "math"
      },
      {
        "rating": 3.162886797,
        "name": "history"
      },
]

我已经尝试过对结果进行分组——这给了我想要的结构——但是由于相同的键,我只得到了一组结果。

当您发布代码来创建图表时,它总是很有帮助的,这样我们就可以给您一个测试过的答案。像这样

g.addV('person').property('name', 'P1').as('p1').
  addV('subject').property('name', 'Math').as('math').
  addV('subject').property('name', 'History').as('history').
  addV('subject').property('name', 'Geography').as('geography').
  addE('likes').from('p1').to('math').property('rating', 1.2).
  addE('likes').from('p1').to('history').property('rating', 2.3).
  addE('likes').from('p1').to('geography').property('rating', 3.4)
我相信你是在试图写一个从某个人开始的遍历,沿着前两个“喜欢”边,得到他喜欢的主题的名称以及相应“喜欢”边上的评级


验证它的工作,非常感谢!不幸的是,我只是图表的下游消费者,无法提供详细信息。