我正在使用一个工作的新词示例的简单变体进行测试,虽然过滤器看起来应该可以工作,但我没有任何运气。我可以对position.length进行过滤,它工作得很好,但我现在尝试基于节点属性进行过滤。
给定这些节点:
node1 = Neography::Node.create("name" => "node1")
node2 = Neography::Node.create("name" => "node2")
person1 = Neography::Node.create("name" => "Person1", "role" => "author")
person2 = Neography::Node.create("name" => "Person2", "role" => "author")
person3 = Neography::Node.create("name" => "Person3", "role" => "editor")
Neography::Relationship.create(:user, node1, person1)
Neography::Relationship.create(:user, node2, person2)
Neography::Relationship.create(:user, node1, person3)
Neography::Relationship.create(:user, node2, person3)在将"the_node“设置为person1的情况下,我尝试让它返回person3:
the_node.both(:user).
order("breadth first").
uniqueness("node global").
#filter("position.length() == 2;").
filter("currentNode.getProperty('role') == 'editor';").
depth(2).
map{|n| n.name}.join(', ')注释掉的筛选器按预期返回person3 (二级关系),但基于'role‘属性的筛选器似乎会过滤所有内容,因此结果为空。
任何建议都会很棒;我对neo4j和新手来说绝对是个新手。
发布于 2012-04-14 05:17:33
我将查看cypher,而不是遍历端点,请参阅http://docs.neo4j.org/chunked/snapshot/cypher-query-lang.html,它受Neography支持
然后,您的查询将类似于
start user = node(1)
match user-[:user]->person
where person.role = "editor"
return person.nameHTH
https://stackoverflow.com/questions/10118373
复制相似问题