Re: [Neo4j] simple traverse question
Ok it's out there on 0.0.11 Thing is when you add a node to an index (before creating the index), Neo4j creates the index on its own. @neo.create_node_index(name, type, provider) # creates an index, defaults are "exact" and "lucene" @neo.create_relationship_index(name, "fulltext") # creates a relationship index with "fulltext" option On Wed, Feb 23, 2011 at 9:57 AM, Max De Marzi Jr. wrote: >>>Since I want to later search for nodes by their mysql_id, do I need to >>>create an index and add the > mysql_id to that index? It appears as if that is the only way to > efficiently find nodes by a key > other than their neo generated ID. Before I went down the path of > creating indexes, I wanted to > make sure that is the correct approach. > > This is one way... the other way is to store the neo_id in the relational db. > >>>It also appears as if the neography gem does not support index creation. > > I'll do it today. > > > > > > On Wed, Feb 23, 2011 at 9:50 AM, charlie wrote: >> Very nice, thanks. >> >> A follow-on question: >> Since I want to later search for nodes by their mysql_id, do I need to >> create an index and add the >> mysql_id to that index? It appears as if that is the only way to >> efficiently find nodes by a key >> other than their neo generated ID. Before I went down the path of creating >> indexes, I wanted to >> make sure that is the correct approach. >> >> It also appears as if the neography gem does not support index creation. I >> can easily curl the >> index creation so it is not a significant issue. I just wanted to make sure >> that I am not missing >> something in my understanding of neography. >> >> thanks again. >> >> Charlie White >> Avvo, Inc. >> 1218 Third Avenue, Suite 300neo.get_node_relationships( >> Seattle, WA 98101 >> >> On Tuesday 22 February 2011 7:48:35 pm Max De Marzi Jr. wrote: >>> Here you go... >>> >>> Full code with setup: >>> >>> https://github.com/maxdemarzi/neography/blob/master/examples/traversal_exam >>>ple2.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 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 >>> > User@li
Re: [Neo4j] simple traverse question
>>Since I want to later search for nodes by their mysql_id, do I need to create >>an index and add the mysql_id to that index? It appears as if that is the only way to efficiently find nodes by a key other than their neo generated ID. Before I went down the path of creating indexes, I wanted to make sure that is the correct approach. This is one way... the other way is to store the neo_id in the relational db. >>It also appears as if the neography gem does not support index creation. I'll do it today. On Wed, Feb 23, 2011 at 9:50 AM, charlie wrote: > Very nice, thanks. > > A follow-on question: > Since I want to later search for nodes by their mysql_id, do I need to create > an index and add the > mysql_id to that index? It appears as if that is the only way to efficiently > find nodes by a key > other than their neo generated ID. Before I went down the path of creating > indexes, I wanted to > make sure that is the correct approach. > > It also appears as if the neography gem does not support index creation. I > can easily curl the > index creation so it is not a significant issue. I just wanted to make sure > that I am not missing > something in my understanding of neography. > > thanks again. > > Charlie White > Avvo, Inc. > 1218 Third Avenue, Suite 300neo.get_node_relationships( > Seattle, WA 98101 > > On Tuesday 22 February 2011 7:48:35 pm Max De Marzi Jr. wrote: >> Here you go... >> >> Full code with setup: >> >> https://github.com/maxdemarzi/neography/blob/master/examples/traversal_exam >>ple2.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 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 >> > User@lists.neo4j.org >> > https://lists.neo4j.org/mailman/listinfo/user >> >> ___ >> Neo4j mailing list >> User@lists.neo4j.org >> https://lists.neo4j.org/mailman/listinfo/user > > > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] simple traverse question
Very nice, thanks. A follow-on question: Since I want to later search for nodes by their mysql_id, do I need to create an index and add the mysql_id to that index? It appears as if that is the only way to efficiently find nodes by a key other than their neo generated ID. Before I went down the path of creating indexes, I wanted to make sure that is the correct approach. It also appears as if the neography gem does not support index creation. I can easily curl the index creation so it is not a significant issue. I just wanted to make sure that I am not missing something in my understanding of neography. thanks again. Charlie White Avvo, Inc. 1218 Third Avenue, Suite 300neo.get_node_relationships( Seattle, WA 98101 On Tuesday 22 February 2011 7:48:35 pm Max De Marzi Jr. wrote: > Here you go... > > Full code with setup: > > https://github.com/maxdemarzi/neography/blob/master/examples/traversal_exam >ple2.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 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 > > User@lists.neo4j.org > > https://lists.neo4j.org/mailman/listinfo/user > > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] simple traverse question
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 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 > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
[Neo4j] simple traverse question
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 User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user