List 小精灵:如何找到其属性*包含*特定值的顶点

List 小精灵:如何找到其属性*包含*特定值的顶点,list,gremlin,vertex,contain,List,Gremlin,Vertex,Contain,假设我的顶点的属性值为列表,例如: g、 addV'v'。属性'prop',['a','b','c'] 如何查找道具包含特定值的情况? 这似乎是显而易见的尝试: g、 V.搭扣在“道具”内,“a” 但它不起作用: gremlin_python.driver.protocol.GremlinServerError:599:找不到方法:DefaultGraphTraversal.has[in[a],test]如果使用文档中所示的VertexProperty列表基数,可以如下完成: >>&

假设我的顶点的属性值为列表,例如:

g、 addV'v'。属性'prop',['a','b','c']

如何查找道具包含特定值的情况? 这似乎是显而易见的尝试:

g、 V.搭扣在“道具”内,“a”

但它不起作用:


gremlin_python.driver.protocol.GremlinServerError:599:找不到方法:DefaultGraphTraversal.has[in[a],test]

如果使用文档中所示的VertexProperty列表基数,可以如下完成:

>>> g.addV('v').property(list_, 'prop', 'a').property(list_, 'prop', 'b').property(list_, 'prop', 'c').next()
v[0]
>>> g.V().has('prop', within('a')).toList()
[v[0]]

请注意,list_uu来自gremlin_python.process.traversal导入基数的枚举

如果使用文档中所示的VertexProperty列表基数,可以按如下方式完成:

>>> g.addV('v').property(list_, 'prop', 'a').property(list_, 'prop', 'b').property(list_, 'prop', 'c').next()
v[0]
>>> g.V().has('prop', within('a')).toList()
[v[0]]

请注意,list_uu来自gremlin_python.process.traversal导入基数的枚举

如果它是一个真实的列表,而不是多值属性,则必须展开该值:

gremlin> g = TinkerGraph.open().traversal()
==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
gremlin> g.addV('v').property('prop',['a','b','c'])
==>v[0]
gremlin> g.V().filter(values('prop').unfold().is('a'))
==>v[0]

// or

gremlin> g.V().has('prop', unfold().is('a'))
==>v[0]

请注意,此筛选器需要对所有顶点进行完全扫描,因为无法为单个列表项编制索引。因此,您应该看看Jason的答案,因为多属性通常是更好的选择。

如果它是一个真实的列表而不是多值属性,那么您必须展开值:

gremlin> g = TinkerGraph.open().traversal()
==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
gremlin> g.addV('v').property('prop',['a','b','c'])
==>v[0]
gremlin> g.V().filter(values('prop').unfold().is('a'))
==>v[0]

// or

gremlin> g.V().has('prop', unfold().is('a'))
==>v[0]
请注意,此筛选器需要对所有顶点进行完全扫描,因为无法为单个列表项编制索引。因此,您应该看看Jason的答案,因为多属性通常是更好的选择