An open API service indexing awesome lists of open source software.

https://github.com/redisgraph/jredisgraph

Java API for RedisGraph
https://github.com/redisgraph/jredisgraph

cypher java-client redis redisgraph

Last synced: 8 months ago
JSON representation

Java API for RedisGraph

Awesome Lists containing this project

README

          

[![license](https://img.shields.io/github/license/RedisGraph/JRedisGraph.svg)](https://github.com/RedisGraph/JRedisGraph/blob/master/LICENSE)
[![GitHub issues](https://img.shields.io/github/release/RedisGraph/JRedisGraph.svg)](https://github.com/RedisGraph/JRedisGraph/releases/latest)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.redislabs/jredisgraph/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.redislabs/jredisgraph)
[![Javadocs](https://www.javadoc.io/badge/com.redislabs/jredisgraph.svg)](https://www.javadoc.io/doc/com.redislabs/jredisgraph)
[![Codecov](https://codecov.io/gh/RedisGraph/JRedisGraph/branch/master/graph/badge.svg)](https://codecov.io/gh/RedisGraph/JRedisGraph)
[![Known Vulnerabilities](https://snyk.io/test/github/RedisGraph/JRedisGraph/badge.svg?targetFile=pom.xml)](https://snyk.io/test/github/RedisGraph/JRedisGraph?targetFile=pom.xml)

# JRedisGraph
[![Forum](https://img.shields.io/badge/Forum-RedisGraph-blue)](https://forum.redislabs.com/c/modules/redisgraph)
[![Discord](https://img.shields.io/discord/697882427875393627?style=flat-square)](https://discord.gg/gWBRT6P)

RedisGraph Java client

## Deprecation notice

As of [Jedis](https://github.com/redis/jedis) version 4.2.0, this library is deprecated. Its features have been merged into Jedis. Please either install it from [maven](https://mvnrepository.com/artifact/redis.clients/jedis) or [the repo](https://github.com/redis/jedis).

### Official Releases

```xml


com.redislabs
jredisgraph
2.5.1


```

### Snapshots
```xml


snapshots-repo
https://oss.sonatype.org/content/repositories/snapshots


```

and

```xml


com.redislabs
jredisgraph
2.6.0-SNAPSHOT


```

## Example: Using the Java Client
```java
package com.redislabs.redisgraph;

import com.redislabs.redisgraph.graph_entities.Edge;
import com.redislabs.redisgraph.graph_entities.Node;
import com.redislabs.redisgraph.graph_entities.Path;
import com.redislabs.redisgraph.impl.api.RedisGraph;

import java.util.List;

public class RedisGraphExample {
public static void main(String[] args) {
// general context api. Not bound to graph key or connection
RedisGraph graph = new RedisGraph();

Map params = new HashMap<>();
params.put("age", 30);
params.put("name", "amit");

// send queries to a specific graph called "social"
graph.query("social","CREATE (:person{name:'roi',age:32})");
graph.query("social","CREATE (:person{name:$name,age:$age})", params);
graph.query("social","MATCH (a:person), (b:person) WHERE (a.name = 'roi' AND b.name='amit') CREATE (a)-[:knows]->(b)");

ResultSet resultSet = graph.query("social", "MATCH (a:person)-[r:knows]->(b:person) RETURN a, r, b");
while(resultSet.hasNext()) {
Record record = resultSet.next();
// get values
Node a = record.getValue("a");
Edge r = record.getValue("r");

//print record
System.out.println(record.toString());
}

resultSet = graph.query("social", "MATCH p = (:person)-[:knows]->(:person) RETURN p");
while(resultSet.hasNext()) {
Record record = resultSet.next();
Path p = record.getValue("p");

// More path API at Javadoc.
System.out.println(p.nodeCount());
}

// delete graph
graph.deleteGraph("social");

// get connection context - closable object
try(RedisGraphContext context = graph.getContext()) {
context.query("contextSocial","CREATE (:person{name:'roi',age:32})");
context.query("social","CREATE (:person{name:$name,age:$age})", params);
context.query("contextSocial", "MATCH (a:person), (b:person) WHERE (a.name = 'roi' AND b.name='amit') CREATE (a)-[:knows]->(b)");
// WATCH/MULTI/EXEC
context.watch("contextSocial");
RedisGraphTransaction t = context.multi();
t.query("contextSocial", "MATCH (a:person)-[r:knows]->(b:person{name:$name,age:$age}) RETURN a, r, b", params);
// support for Redis/Jedis native commands in transaction
t.set("x", "1");
t.get("x");
// get multi/exec results
List execResults = t.exec();
System.out.println(execResults.toString());

context.deleteGraph("contextSocial");
}
}
}

```

## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FRedisGraph%2FJRedisGraph.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FRedisGraph%2FJRedisGraph?ref=badge_large)