Giter Site home page Giter Site logo

pombredanne / redisgraph Goto Github PK

View Code? Open in Web Editor NEW

This project forked from redisgraph/redisgraph

0.0 1.0 0.0 10.67 MB

A graph database as a Redis module

Home Page: https://oss.redislabs.com/redisgraph/

License: Other

Dockerfile 0.05% Makefile 0.64% C 75.85% Objective-C 0.03% C++ 11.86% Yacc 1.10% Lex 0.17% Python 8.14% Gherkin 2.16%

redisgraph's Introduction

GitHub issues CircleCI DockerHub

RedisGraph - A graph database module for Redis

RedisGraph is the first queryable Property Graph database to use sparse matrices to represent the adjacency matrix in graphs and linear algebra to query the graph.

Primary features:

  • Adopting the Property Graph Model
    • Nodes (vertices) and Relationships (edges) that may have attributes
    • Nodes that can be labeled
    • Relationships have a relationship type
  • Graphs represented as sparse adjacency matrices
  • Cypher as query language
    • Cypher queries translated into linear algebra expressions

To see RedisGraph in action, visit Demos.

Quickstart

  1. Docker
  2. Build
  3. Start
  4. Use from any client

Docker

To quickly tryout RedisGraph, launch an instance using docker:

docker run -p 6379:6379 -it --rm redislabs/redisgraph

Give it a try

Once loaded you can interact with RedisGraph using redis-cli.

Here we'll quickly create a small graph representing a subset of motorcycle riders and teams taking part in the MotoGP league, once created we'll start querying our data.

With redis-cli

$ redis-cli
127.0.0.1:6379> GRAPH.QUERY MotoGP "CREATE (:Rider {name:'Valentino Rossi'})-[:rides]->(:Team {name:'Yamaha'}), (:Rider {name:'Dani Pedrosa'})-[:rides]->(:Team {name:'Honda'}), (:Rider {name:'Andrea Dovizioso'})-[:rides]->(:Team {name:'Ducati'})"
1) (empty list or set)
2) 1) Labels added: 2
   2) Nodes created: 6
   3) Properties set: 6
   4) Relationships created: 3
   5) "Query internal execution time: 0.399000 milliseconds"

Now that our MotoGP graph is created, we can start asking questions, for example: Who's riding for team Yamaha?

127.0.0.1:6379> GRAPH.QUERY MotoGP "MATCH (r:Rider)-[:rides]->(t:Team) WHERE t.name = 'Yamaha' RETURN r,t"
1) 1) 1) "r.name"
      2) "t.name"
   2) 1) "Valentino Rossi"
      2) "Yamaha"
2) 1) "Query internal execution time: 0.122000 milliseconds"

How many riders represent team Ducati?

127.0.0.1:6379> GRAPH.QUERY MotoGP "MATCH (r:Rider)-[:rides]->(t:Team {name:'Ducati'}) RETURN count(r)"
1) 1) 1) "count(r)"
   2) 1) "1.000000"
2) 1) "Query internal execution time: 0.129000 milliseconds"

Building

Linux Ubuntu 16.04

Requirements:

  • The RedisGraph repository: git clone https://github.com/RedisLabsModules/RedisGraph.git
  • The build-essential and cmake packages: apt-get install build-essential cmake

To build, run make in the project's directory

Congratulations! You can find the compiled binary at src/redisgraph.so.

Loading RedisGraph into Redis

RedisGraph is hosted by Redis, so you'll first have to load it as a Module to a Redis server: running Redis v4.0 or above.

We recommend having Redis load RedisGraph during startup by adding the following to your redis.conf file:

loadmodule /path/to/module/src/redisgraph.so

In the line above, replace /path/to/module/src/redisgraph.so with the actual path to RedisGraph's library.

Alternatively, you can have Redis load RedisGraph using the following command line argument syntax:

~/$ redis-server --loadmodule /path/to/module/src/redisgraph.so

Lastly, you can also use the MODULE LOAD command. Note, however, that MODULE LOAD is a dangerous command and may be blocked/deprecated in the future due to security considerations.

Once you've successfully loaded RedisGraph your Redis log should have lines similar to:

...
30707:M 20 Jun 02:08:12.314 * Module 'graph' loaded from <redacted>/src/redisgraph.so
...

Using RedisGraph

You can call RedisGraph's commands from any Redis client.

With redis-cli

$ redis-cli
127.0.0.1:6379> GRAPH.QUERY social "CREATE (:person {name: 'roi', age: 33, gender: 'male', status: 'married'})"

With any other client

You can interact with RedisGraph using your client's ability to send raw Redis commands.

Depending on your client of choice, the exact method for doing that may vary.

Python example

This code snippet shows how to use RedisGraph with raw Redis commands from Python via redis-py:

import redis

r = redis.StrictRedis()
reply = r.execute_command('GRAPH.QUERY', 'social', "CREATE (:person {name:'roi', age:33, gender:'male', status:'married')")

Client libraries

Some languages have client libraries that provide support for RedisGraph's commands:

Project Language License Author URL
redisgraph-py Python BSD Redis Labs GitHub
JRedisGraph Java BSD Redis Labs GitHub
redisgraph-rb Ruby BSD Redis Labs GitHub
redisgraph-go Go BSD Redis Labs GitHub
redisgraph.js JavaScript BSD Redis Labs GitHub
php-redis-graph PHP MIT KJDev GitHub

Documentation

Read the docs at redisgraph.io.

Mailing List / Forum

Got questions? Feel free to ask at the RediGraph mailing list.

License

Apache 2.0 with Commons Clause - see LICENSE

redisgraph's People

Contributors

davidboden avatar davisford avatar gkorland avatar itamarhaber avatar jeffreylovitz avatar k-jo avatar matthiaswinkelmann avatar serdaroquai avatar swilly22 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.