具有Gremlin的属性的后缘与源顶点上的一个相匹配

时间:2019-02-05 12:04:56

标签: azure-cosmosdb graph-databases gremlin tinkerpop

我有一个图,我想沿着包含与顶点上的一个属性相匹配的属性的边。例如

vertex         -------edge ---------> vertex
vertValue: 123        vert: 123       vertValue: 463

因此,在上述情况下,假设我从第一个顶点开始,我想跟随属性“ vert”等于其“ vertValue”的边。

我设法使用where进行查询,该查询设法顺应了要求:

g.V(id).as('verts')
  .outE().values('vert')
  .where(eq('verts'))
    .by('vertValue')

问题,是我要返回实际的边缘对象。但是,由于我需要在边缘的“垂直”值上执行“位置”,因此在查询中,我正在执行values('vert'),所以得到的结果只是我正在测试的值,而不是边缘对象。我想做类似的事情:

g.V(id).as('verts')
  .outE()
  .where(eq('verts'))
    .by('vertValue','vert')

将顶点上的“ vertValue”与边缘上的“ vert”值进行比较。但是我似乎找不到找到在where的“输入”值上指定by的方法。

修改:尝试:

g.V("95c4a57a-9262-45b7-a905-8cca95d3ebb6").as('v').
  outE().
  where(eq('v')).
    by('vert').
    by('vertValue')

返回错误:

  

克里姆林宫查询执行错误:选择一个:获取投影:提供的path()遍历或属性名称未映射到值。

g.V("95c4a57a-9262-45b7-a905-8cca95d3ebb6").as('v').
  outE().
  where(eq('v')).
    by('vertValue').
    by('vert')

返回一个空数组!

1 个答案:

答案 0 :(得分:0)

您真的很了解解决方案。是:

    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
      if (this.readyState == 4 && this.status == 200) {
         $('item', this.responseText).each(function(){
             var thisPostData = {};
             thisPostData.title = $(this).find('title').text();
             thisPostData.link = $(this).find('link').text();
             thisPostData.date = $(this).find('pubDate').text();
             posts.push(thisPostData);
          });
          console.log(posts);
       }
     };
   var posts = [];
   xhttp.open('GET', 'https://example.com/rssfeed/', true);
   xhttp.send();
相关问题