Neo4j gremlin查询以从属性中删除其中一个值
我试图找到一种方法来删除顶点上属性(字符串列表)中的特定值。顶点有多个属性,其中一个属性是字符串列表 e、 g 例如,我正在寻找一个从列表中删除属性值“a”的查询,操作完成后,应列出关于查询的o/pNeo4j gremlin查询以从属性中删除其中一个值,neo4j,gremlin,Neo4j,Gremlin,我试图找到一种方法来删除顶点上属性(字符串列表)中的特定值。顶点有多个属性,其中一个属性是字符串列表 e、 g 例如,我正在寻找一个从列表中删除属性值“a”的查询,操作完成后,应列出关于查询的o/p gremlin> g.V().hasLabel('ACCOUNT').or(has('Name', '123')).properties() ==>vp[Value->b] ==>vp[Value->c] 我使用neo4j作为数据库。您可以遍历顶点属性,然后过滤匹配值
gremlin> g.V().hasLabel('ACCOUNT').or(has('Name', '123')).properties()
==>vp[Value->b]
==>vp[Value->c]
我使用neo4j作为数据库。您可以遍历顶点属性,然后过滤匹配值,然后删除这些属性。另请参阅TinkerPop文档中的
gremlin> Gremlin.version()
==>3.2.9
gremlin> // create the vertices
gremlin> g.addV('ACCOUNT').
......1> property(list, 'Value', 'a').
......2> property(list, 'Value', 'b').
......3> property(list, 'Value', 'c').
......4> iterate()
gremlin> g.addV('PERSON').
......1> property('Name', '123').
......2> property(list, 'Value', 'a').
......3> property(list, 'Value', 'b').
......4> property(list, 'Value', 'c').
......5> iterate()
gremlin> // show all properties (before)
gremlin> g.V().or(hasLabel('ACCOUNT'), has('Name', '123')).
......1> project('label', 'props').
......2> by(label()).by(properties().fold())
==>[label:ACCOUNT,props:[vp[Value->a],vp[Value->b],vp[Value->c]]]
==>[label:PERSON,props:[vp[Value->a],vp[Value->b],vp[Value->c],vp[Name->123]]]
gremlin> // drop only the matching property
gremlin> g.V().or(hasLabel('ACCOUNT'), has('Name', '123')).properties('Value').
......1> hasValue('a').
......2> drop().iterate()
gremlin> // show all properties (after)
gremlin> g.V().or(hasLabel('ACCOUNT'), has('Name', '123')).
......1> project('label', 'props').
......2> by(label()).by(properties().fold())
==>[label:ACCOUNT,props:[vp[Value->b],vp[Value->c]]]
==>[label:PERSON,props:[vp[Value->b],vp[Value->c],vp[Name->123]]]
可以遍历到顶点特性,然后过滤匹配值,然后删除这些特性。另请参阅TinkerPop文档中的
gremlin> Gremlin.version()
==>3.2.9
gremlin> // create the vertices
gremlin> g.addV('ACCOUNT').
......1> property(list, 'Value', 'a').
......2> property(list, 'Value', 'b').
......3> property(list, 'Value', 'c').
......4> iterate()
gremlin> g.addV('PERSON').
......1> property('Name', '123').
......2> property(list, 'Value', 'a').
......3> property(list, 'Value', 'b').
......4> property(list, 'Value', 'c').
......5> iterate()
gremlin> // show all properties (before)
gremlin> g.V().or(hasLabel('ACCOUNT'), has('Name', '123')).
......1> project('label', 'props').
......2> by(label()).by(properties().fold())
==>[label:ACCOUNT,props:[vp[Value->a],vp[Value->b],vp[Value->c]]]
==>[label:PERSON,props:[vp[Value->a],vp[Value->b],vp[Value->c],vp[Name->123]]]
gremlin> // drop only the matching property
gremlin> g.V().or(hasLabel('ACCOUNT'), has('Name', '123')).properties('Value').
......1> hasValue('a').
......2> drop().iterate()
gremlin> // show all properties (after)
gremlin> g.V().or(hasLabel('ACCOUNT'), has('Name', '123')).
......1> project('label', 'props').
......2> by(label()).by(properties().fold())
==>[label:ACCOUNT,props:[vp[Value->b],vp[Value->c]]]
==>[label:PERSON,props:[vp[Value->b],vp[Value->c],vp[Name->123]]]
在他的示例中,他实际上只有一个顶点,
Name
属性与帐户
顶点相关。或()。另外,您不需要lambda过滤器步骤,它只是…属性('Value')。hasValue('a')
,谢谢,您是对的。我将用hasValue('a')
更新答案。最初的问题在顶点上根本没有名称
属性,否则它将被列为结果中的属性之一。这就是为什么我在示例中创建了两个独立的顶点;)在他的示例中,他实际上只有一个顶点,Name
属性与帐户
顶点相关。或()。另外,您不需要lambda过滤器步骤,它只是…属性('Value')。hasValue('a')
,谢谢,您是对的。我将用hasValue('a')
更新答案。最初的问题在顶点上根本没有名称
属性,否则它将被列为结果中的属性之一。这就是为什么我在示例中创建了两个独立的顶点;)