使用Gremlin和DSE-Graph哪个数据建模更适合此hypergraph性能?

使用Gremlin和DSE-Graph哪个数据建模更适合此hypergraph性能?,graph,datastax-enterprise,gremlin,datastax-enterprise-graph,hypergraph,Graph,Datastax Enterprise,Gremlin,Datastax Enterprise Graph,Hypergraph,我有这样一个场景:每个(源)实体都有一个指向另一个实体的属性。这些属性映射被分组在一起。我要做的是查询那些具有特定属性且具有相应目标但位于同一组下的实体 hypergraph会这样(矩形是超边): JSON的JSON如下所示: { id: 1, label: "Entity", propertyGroups: [ { propertyGroupUuid: GroupUuid1, property: {id: 1, label: "

我有这样一个场景:每个(源)
实体
都有一个指向另一个
实体的
属性
。这些属性映射被分组在一起。我要做的是查询那些具有特定属性且具有相应目标但位于同一组下的实体

hypergraph会这样(矩形是超边):

JSON的
JSON
如下所示:

{ 
    id: 1, label: "Entity", 
    propertyGroups: [
    { 
        propertyGroupUuid: GroupUuid1, 
        property: {id: 1, label: "Property", name: "aName1"},
        target: {id: 2, label: "Entity"}
    },
    { 
        propertyGroupUuid: GroupUuid2, 
        property: {id: 2, label: "Property", name: "aName2"},
        target: {id: 3, label: "Entity"}
    },
    { 
        propertyGroupUuid: GroupUuid2, 
        property: {id: 3, label: "Property", name: "aName3"},
        target: {id: 4, label: "Entity"}
    }]
}
graph数据库中最扁平的版本可能如下所示:

{ 
    id: 1, label: "Entity", 
    propertyGroups: [
    { 
        propertyGroupUuid: GroupUuid1, 
        property: {id: 1, label: "Property", name: "aName1"},
        target: {id: 2, label: "Entity"}
    },
    { 
        propertyGroupUuid: GroupUuid2, 
        property: {id: 2, label: "Property", name: "aName2"},
        target: {id: 3, label: "Entity"}
    },
    { 
        propertyGroupUuid: GroupUuid2, 
        property: {id: 3, label: "Property", name: "aName3"},
        target: {id: 4, label: "Entity"}
    }]
}

虽然它的最扩展版本可能如下所示:

{ 
    id: 1, label: "Entity", 
    propertyGroups: [
    { 
        propertyGroupUuid: GroupUuid1, 
        property: {id: 1, label: "Property", name: "aName1"},
        target: {id: 2, label: "Entity"}
    },
    { 
        propertyGroupUuid: GroupUuid2, 
        property: {id: 2, label: "Property", name: "aName2"},
        target: {id: 3, label: "Entity"}
    },
    { 
        propertyGroupUuid: GroupUuid2, 
        property: {id: 3, label: "Property", name: "aName3"},
        target: {id: 4, label: "Entity"}
    }]
}

因此,如果我想:

  • 获取分别在同一PropertyGroupUuid“targeting”
    实体3
    实体4
    下具有
    属性2
    属性3
    的所有
    实体,我应该返回
    实体1
  • 获取在同一PropertyGroupUuid“targeting”
    实体2
    实体3
    下分别具有
    属性1
    属性2
    的所有
    实体,我应该返回
    实体1
如何使用gremlin针对两个版本的图实现这一点?使用正确的索引(如DSE graph中包含的索引),哪一个更灵活/性能更好?有没有我没想到的更好的选择?如果答案详细且解释清楚,我将给予至少50英镑的赏金:)


谢谢大家!

我不理解您的第一个具有解耦属性节点的模型,但下面是模型2的遍历:

g.V().has("Property", "name", "Property 2").in("hasProperty"). /* start at any of the property 2  */
  filter(out("hasTarget").has("name", "Entity 3")).            /*   with target entity 3          */
  in("hasSubGroup").filter(                                    /* traverse to the property group  */
    out("hasSubGroup").and(                                    /* traverse to all sub-groups      */
      out("hasProperty").has("name", "Property 3"),            /* filter those that are linked to */
      out("hasTarget").has("name", Entity 4")                  /*   property 3 w/ target entity 4  */
    )
  ).in("hasGroup")                                             /* traverse to all entities that match the above criteria */

由于对图形中的数据一无所知,因此很难预测此遍历的性能。但一般来说,如果a)属性名被索引,b)分支因子较低,那么性能应该是可以的。

你把我搞糊涂了,因为你把属性显示为节点。通常,超边被实现为节点。仅查看初始图,您将添加三个HE节点,三个矩形各一个,并添加从每个实体到其所在的每个HE节点的链接。如果属性和属性组是节点,那么它们也会有指向其包含节点的链接。是的,我的属性实际上是具有名称的对象,而不是图形属性。。这就是我将它们作为节点的原因。那么如何访问“属性”
g.V().has(“Property”、“name”、“Property 1”)
?@Daniel是的,物业名称或其ID当然是唯一的谢谢Daniel!第一个模型具有解耦的属性,因此我可以查找ID和名称。。它肯定可以储存在卡桑德拉或其他地方。我通常采用第二种方法,因此不确定第一种方法是否可行。分支因子是指每个实体上有多少属性子树?我发现键入的
has(“name”,“Property 4”)
需要
has(“name”,“Entity 4”)
。此外,您在哪里检查属性2和属性3的子组是否相同或不同?我希望使用
as()
会有更明确的内容。谢谢可能是
在(“hasSubGroup”).filter(
需要
在(“hasSubGroup”).filter(
你的打字错误是对的,但其余的对我来说都不错。所谓“分支因子”,我指的是每个
属性组和
属性子组的外边缘数。