Here you go...

Full code with setup:

https://github.com/maxdemarzi/neography/blob/master/examples/traversal_example2.rb

Interesting bit:

def graduated_with_me(student)
  student = student["self"].split('/').last
  student_attended = @neo.get_node_relationships(student)[0]
  graduated = student_attended["data"]["graduated"]
  school = student_attended["end"].split('/').last

  @neo.traverse(school,"nodes", {"order" => "breadth first",
                                          "uniqueness" => "node global",
                                          "relationships" => {"type"=>
"attended", "direction" => "in"},
                                          "return filter" => {
                                            "language" => "javascript",
                                            "body" => "position.length() == 1
                                                       &&
position.endNode().getId() != #{student}
                                                       &&
position.lastRelationship().getProperty(\"graduated\") ==
#{graduated};"}})
end


Visualize it (sort of... I need to add relationship properties):
http://neovigator.heroku.com/?neoid=201

Neo4j guys, how do we use the new Evaluator via Rest?

Thanks,
Max


On Tue, Feb 22, 2011 at 6:50 PM, charlie <[email protected]> wrote:
> Hi,
> I am new to neo4j and I am having some difficulty figuring out how to query 
> it to get me what I
> need.  We are using Ruby and not JRuby so I am trying to do all my queries 
> via the REST API.
>
> Currently I have a set of "people" nodes and a set of "school" nodes.  Each 
> node has an id field and
> a name.  The ID field is not to be confused with the ID field assigned by 
> neo, but rather a key
> into a relational database elsewhere.
> I have created a people and school index so I can find the nodes by ids
> curl -H Accept:application/json 
> http://localhost:7474/db/data/index/node/person/person_id/28995
>
> I have also created relationships between each person and school called 
> "attended".  I set a
> graduation date and degree name as attributes of each attended relationship.
>
> The query that I want to find all people that attended the same school as I 
> did and graduated at the
> same time.
> person => school => person1, person2, ... personN.
>
>
> More advanced:
> Later I might want to add to that people with the same degree as well as 
> graduation date.  And,
> after that, I would probably want to find "friends" of those same people.   
> Of course that implies
> that I added a relationship of "firend" between people.
>
> Any help that you can provide me on this would be helpful.  I think that once 
> I get started with a
> couple of examples, I will be able to take off.
>
> thanks,
>
> Charlie White
> Avvo, Inc.
> 1218 Third Avenue, Suite 300
> Seattle, WA 98101
> _______________________________________________
> Neo4j mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user
>
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to