Book Image

Neo4j Cookbook

By : Ankur goel, Ankur Goel
Book Image

Neo4j Cookbook

By: Ankur goel, Ankur Goel

Overview of this book

Table of Contents (17 chapters)
Neo4j Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Accessing Neo4j from Ruby using the REST Bindings


In this recipe, we will learn how to access the Neo4j graph database server from Ruby using the REST bindings.

Getting ready

The Neo4j REST server can be accessed using an excellent neography gem module, which claims to be a thin wrapper over the Neo4j REST API interface.

The following steps will get you started with neography gem:

  1. The neography gem modules can be installed on the machine using the gem install command:

    gem install 'neography'
    
  2. The neography module also requires the gem module in the Ruby code, so configure and initialize the neography gem modules with the following code:

    @graph = Neography::Rest.new({ :protocol   => 'http://',
                                   :server     => IP_ADDRESS,
                                   :port       => PORT,
    })

How to do it...

Follow these steps to go through this recipe:

  1. Let's create our graph using neography using the following code:

    node1 = @graph.create_node("name" => "A")
    node2 = @graph...