JRedisGraph icon indicating copy to clipboard operation
JRedisGraph copied to clipboard

Redis Graph 1.0.6 not working

Open nmarquesantos opened this issue 6 years ago • 1 comments

Hey chaps

I'm trying to run the example before version 2.0.0, and it just doesn't work.

Steps to reproduce:

  1. Spin up redis graph container

docker run -d --name redis-p 6379:6379 redislabs/redisgraph

  1. Import JRedis 1.0.6

<dependencies> <dependency> <groupId>com.redislabs</groupId> <artifactId>jredisgraph</artifactId> <version>1.0.6</version> </dependency> </dependencies>

  1. Copy example in repository readme
public class RedisGraphExample {
	public static void main(String[] args) {

		RedisGraphAPI api = new RedisGraphAPI("social");

		api.query("CREATE (:person{name:'roi',age:32})");
		api.query("CREATE (:person{name:%s,age:%d})", "amit", 30);

		api.query("MATCH (a:person), (b:person) WHERE (a.name = 'roi' AND b.name='amit') CREATE (a)-[:knows]->(b)");

		ResultSet resultSet = api.query("MATCH (a:person)-[:knows]->(b:person) RETURN a, b");

		while(resultSet.hasNext()){
			Record record = resultSet.next();
			System.out.println(record.getString("a.name"));
		}
	}
}

Issues:

  1. This line does not work as t here is no query method with more than one argument api.query("CREATE (:person{name:%s,age:%d})", "amit", 30);

  2. By commenting out the above line, we can now attempt to run the code which returns the following error:

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 at java.util.ArrayList.rangeCheck(ArrayList.java:657) at java.util.ArrayList.get(ArrayList.java:433) at com.redislabs.redisgraph.impl.ResultSetImpl.<init>(ResultSetImpl.java:24) at com.redislabs.redisgraph.RedisGraphAPI.query(RedisGraphAPI.java:58) at Main.main(Main.java:11)

nmarquesantos avatar Dec 25 '19 14:12 nmarquesantos

hi @nmarquesantos from redis-cli execute the command module list you should see the following:

127.0.0.1:6379> module list
1) 1) "name"
   2) "graph"
   3) "ver"
   4) (integer) 19901

This means that the graph version is 1.99.1, which is the first milestone towards 2.0 release. In 1.99.* we changed the query response structure, so JRedisGraph 1.0.6 does not support this new structure. For a better experience, I suggest that you use either latest docker tag, which is our latest milestone release or edge docker which is RedisGraph master branch build. As for JRedisGraph, I suggest that you use the latest RC as it supports our latest features in RedisGraph, such as parameters and path objects response.

DvirDukhan avatar Dec 25 '19 18:12 DvirDukhan