-
Notifications
You must be signed in to change notification settings - Fork 276
Neo4j::core introduction
andreasronge edited this page Oct 4, 2012
·
7 revisions
This gem is only a thin JRuby wrapper around the Neo4j Java API. It does not wrap nodes in Ruby object. It can be used instead of the neo4j-wrapper or neo4j gems when you don't need a Ruby mapping for relationships and nodes, check the GitHub Project.
- Neo4j::Node
- Neo4j::Relationship
- Neo4j - e.g. cypher query
- Neo4j::Algo included algorithms, like shortest path
- Neo4j::Config
- Neo4j::Transaction
require 'neo4j-core'
Neo4j::Transaction.run do
andreas = Neo4j::Node.new(:name => 'andreas')
peter = Neo4j::Node.new(:name => 'peter')
Neo4j::Relationship.new(:friends, andreas, peter, :since => 2008)
Neo4j.ref_node.outgoing(:people) << andreas << peter
end
# Traversal API and Ruby Enumerable
Neo4j.ref_node.outgoing(:people).count # => 2
Neo4j.ref_node.outgoing(:people).find{|n| n[:name] == 'andreas'}.props # => {"_neo_id"=>7, "name"=>"andreas"}
# The same in Cypher, check the cypher DSL docs !
# the following line returns 2
Neo4j.query(Neo4j.ref_node) {|ref_node| ref_node.outgoing(:people).count.as(:nbr_people)}.first[:nbr_people]
# The following line returns [:v1]
Neo4j.query(Neo4j.ref_node) {|ref_node| ref_node.outgoing(:people)[:name] == 'andreas'}.columns
# The following line returns {"_neo_id"=>7, "name"=>"andreas"}
Neo4j.query(Neo4j.ref_node) {|ref_node| ref_node.outgoing(:people)[:name] == 'andreas'}.first[:v1].props
rvm use jruby-1.7.0.RC1
gem install neo4j-core
It only works with JRuby !
WARNING: Much of the information in this wiki is out of date. We are in the process of moving things to readthedocs
- Project Introduction
- Neo4j::ActiveNode
- Neo4j::ActiveRel
- Search and Scope
- Validation, Uniqueness, and Case Sensitivity
- Indexing VS Legacy Indexing
- Optimized Methods
- Inheritance
- Core: Nodes & Rels
- Introduction
- Persistence
- Find : Lucene
- Relationships
- Third Party Gems & extensions
- Scaffolding & Generators
- HA Cluster