All Projects → RedisGraph → redisgraph-go

RedisGraph / redisgraph-go

Licence: BSD-3-Clause License
A Golang client for redisgraph

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to redisgraph-go

JRedisGraph
Java API for RedisGraph
Stars: ✭ 56 (-43.43%)
Mutual labels:  cypher, redisgraph
seabolt
Neo4j Bolt Connector for C
Stars: ✭ 37 (-62.63%)
Mutual labels:  cypher
decypher
A handful of cypher utilities for Node.js
Stars: ✭ 34 (-65.66%)
Mutual labels:  cypher
redis-developer.github.io
The Home of Redis Developers
Stars: ✭ 28 (-71.72%)
Mutual labels:  redisgraph
redisplanet
Redisplanet - An Ultimate Hands-on Labs on Redis
Stars: ✭ 24 (-75.76%)
Mutual labels:  redisgraph
neo4j-ml-procedures
This project provides procedures and functions to support machine learning applications with Neo4j.
Stars: ✭ 37 (-62.63%)
Mutual labels:  cypher
Numenera-FoundryVTT
Numenera support for the Foundry virtual tabletop
Stars: ✭ 26 (-73.74%)
Mutual labels:  cypher
sqerzo
Tiny ORM for graph databases: Neo4j, RedisGraph, AWS Neptune or Gremlin
Stars: ✭ 28 (-71.72%)
Mutual labels:  redisgraph
legis-graph
ETL scripts for loading US Congressional data from govtrack.us into Neo4j
Stars: ✭ 48 (-51.52%)
Mutual labels:  cypher
mage
MAGE - Memgraph Advanced Graph Extensions 🔮
Stars: ✭ 89 (-10.1%)
Mutual labels:  cypher
Graph-OLAP
An attempt to model an OLAP cube with Neo4j.
Stars: ✭ 37 (-62.63%)
Mutual labels:  cypher
neo4j-graphql-java
Pure JVM translation for GraphQL queries and mutations to Neo4j's Cypher
Stars: ✭ 94 (-5.05%)
Mutual labels:  cypher
cytosm
OpenCypher to SQL Mapper
Stars: ✭ 65 (-34.34%)
Mutual labels:  cypher
civogo
Golang client to interact with Civo's API
Stars: ✭ 29 (-70.71%)
Mutual labels:  golang-client
markransom
Simple but sharp ransomware
Stars: ✭ 25 (-74.75%)
Mutual labels:  cypher
ml-models
Machine Learning Procedures and Functions for Neo4j
Stars: ✭ 63 (-36.36%)
Mutual labels:  cypher
NeoClient
🦉 Lightweight OGM for Neo4j which support transactions and BOLT protocol.
Stars: ✭ 21 (-78.79%)
Mutual labels:  cypher
mgmigrate
mgmigrate is a tool for migrating data from MySQL or PostgreSQL to Memgraph and between Memgraph instances.
Stars: ✭ 17 (-82.83%)
Mutual labels:  cypher
gogm
Golang Object Graph Mapper for Neo4j
Stars: ✭ 71 (-28.28%)
Mutual labels:  cypher
neo4rs
Neo4j driver for rust
Stars: ✭ 41 (-58.59%)
Mutual labels:  cypher

license CircleCI GitHub issues Codecov Go Report Card GoDoc

redisgraph-go

Forum Discord

redisgraph-go is a Golang client for the RedisGraph module. It relies on redigo for Redis connection management and provides support for RedisGraph's QUERY, EXPLAIN, and DELETE commands.

Installation

Simply do:

$ go get github.com/redislabs/redisgraph-go

Usage

The complete redisgraph-go API is documented on GoDoc.

package main

import (
	"fmt"
	"os"

	"github.com/gomodule/redigo/redis"
	rg "github.com/redislabs/redisgraph-go"
)

func main() {
	conn, _ := redis.Dial("tcp", "127.0.0.1:6379")
	defer conn.Close()

	graph := rg.GraphNew("social", conn)

	graph.Delete()

	john := rg.Node{
		Label: "person",
		Properties: map[string]interface{}{
			"name":   "John Doe",
			"age":    33,
			"gender": "male",
			"status": "single",
		},
	}
	graph.AddNode(&john)

	japan := rg.Node{
		Label: "country",
		Properties: map[string]interface{}{
			"name": "Japan",
		},
	}
	graph.AddNode(&japan)

	edge := rg.Edge{
		Source:      &john,
		Relation:    "visited",
		Destination: &japan,
	}
	graph.AddEdge(&edge)

	graph.Commit()

	query := `MATCH (p:person)-[v:visited]->(c:country)
           RETURN p.name, p.age, c.name`

	// result is a QueryResult struct containing the query's generated records and statistics.
	result, _ := graph.Query(query)

	// Pretty-print the full result set as a table.
	result.PrettyPrint()

	// Iterate over each individual Record in the result.
	fmt.Println("Visited countries by person:")
	for result.Next() { // Next returns true until the iterator is depleted.
		// Get the current Record.
		r := result.Record()

		// Entries in the Record can be accessed by index or key.
		pName := r.GetByIndex(0)
		fmt.Printf("\nName: %s\n", pName)
		pAge, _ := r.Get("p.age")
		fmt.Printf("\nAge: %d\n", pAge)
	}

	// Path matching example.
	query = "MATCH p = (:person)-[:visited]->(:country) RETURN p"
	result, err := graph.Query(query)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	fmt.Println("Pathes of persons visiting countries:")
	for result.Next() {
		r := result.Record()
		p, ok := r.GetByIndex(0).(rg.Path)
		fmt.Printf("%s %v\n", p, ok)
	}
}

Running the above produces the output:

+----------+-------+--------+
|  p.name  | p.age | c.name |
+----------+-------+--------+
| John Doe |    33 | Japan  |
+----------+-------+--------+

Query internal execution time 1.623063

Name: John Doe

Age: 33

Running queries with timeouts

Queries can be run with a millisecond-level timeout as described in the module documentation. To take advantage of this feature, the QueryOptions struct should be used:

options := NewQueryOptions().SetTimeout(10) // 10-millisecond timeout
res, err := graph.QueryWithOptions("MATCH (src {name: 'John Doe'})-[*]->(dest) RETURN dest", options)

ParameterizedQueryWithOptions and ROQueryWithOptions endpoints are also exposed by the client.

Running tests

A simple test suite is provided, and can be run with:

$ go test

The tests expect a Redis server with the RedisGraph module loaded to be available at localhost:6379

License

redisgraph-go is distributed under the BSD3 license - see LICENSE

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].