Redis is phasing out RedisGraph. This blog post explains the motivation behind this decision and the implications for existing Redis customers and community members.
End of support is scheduled for January 31, 2025.
RedisGraph is the fastest graph database that processes complex graph operations in real time, 10x – 600x faster than any other graph database. Show how your data is connected through multiple visualization integrations including RedisInsight, Linkurious, and Graphileon. Query graphs using the industry-standard Cypher query language and easily use graph capabilities from application code.
Follow the steps below to get started with RedisGraph with Java:
docker run -p 6379:6379 --name redis/redis-stack
info modules
# Modules
module:name=graph,ver=20405,api=1,filters=0,usedby=[],using=[],options=[]
git clone https://github.com/RedisGraph/redisgraph.js
npm install redisgraph.js
const RedisGraph = require('redisgraph.js').Graph;
let graph = new RedisGraph('social');
(async () => {
await graph.query("CREATE (:person{name:'roi',age:32})");
await graph.query("CREATE (:person{name:'amit',age:30})");
await graph.query(
"MATCH (a:person), (b:person) WHERE (a.name = 'roi' AND b.name='amit') CREATE (a)-[:knows]->(b)",
);
// Match query.
let res = await graph.query(
'MATCH (a:person)-[:knows]->(:person) RETURN a.name',
);
while (res.hasNext()) {
let record = res.next();
console.log(record.get('a.name'));
}
console.log(res.getStatistics().queryExecutionTime());
// Match with parameters.
let param = { age: 30 };
res = await graph.query('MATCH (a {age: $age}) return a.name', param);
while (res.hasNext()) {
let record = res.next();
console.log(record.get('a.name'));
}
// Named paths matching.
res = await graph.query('MATCH p = (a:person)-[:knows]->(:person) RETURN p');
while (res.hasNext()) {
let record = res.next();
// See path.js for more path API.
console.log(record.get('p').nodeCount);
}
graph.deleteGraph();
graph.close();
})();
Save the above file as "app.js".
node app.js
roi
0.1789
amit
2
1632898652.415702 [0 172.17.0.1:64144] "info"
1632898652.418225 [0 172.17.0.1:64144] "graph.query" "social" "CREATE (:person{name:'roi',age:32})" "--compact"
1632898652.420399 [0 172.17.0.1:64144] "graph.query" "social" "CREATE (:person{name:'amit',age:30})" "--compact"
1632898652.421857 [0 172.17.0.1:64144] "graph.query" "social" "MATCH (a:person), (b:person) WHERE (a.name = 'roi' AND b.name='amit') CREATE (a)-[:knows]->(b)" "--compact"
1632898652.424911 [0 172.17.0.1:64144] "graph.query" "social" "MATCH (a:person)-[:knows]->(:person) RETURN a.name" "--compact"
1632898652.429658 [0 172.17.0.1:64144] "graph.query" "social" "CYPHER age=30 MATCH (a {age: $age}) return a.name" "--compact"
1632898652.431221 [0 172.17.0.1:64144] "graph.query" "social" "MATCH p = (a:person)-[:knows]->(:person) RETURN p" "--compact"
1632898652.433146 [0 172.17.0.1:64144] "graph.query" "social" "CALL db.labels()" "--compact"
1632898652.434781 [0 172.17.0.1:64144] "graph.query" "social" "CALL db.propertyKeys()" "--compact"
1632898652.436574 [0 172.17.0.1:64144] "graph.query" "social" "CALL db.relationshipTypes()" "--compact"
1632898652.438559 [0 172.17.0.1:64144] "graph.delete" "social"
Run the RedisInsight container. The easiest way is to run the following command:
docker run -d -v redisinsight:/db -p 8001:8001 redislabs/redisinsight:latest
Next, point your browser to http://localhost:8001.
You can display the number of records returned by a query: