Closed marcoippolito closed 5 years ago
In Ubuntu 18.04.01 Server Edition I installed redis-server:
marco@pc01:~$ redis-server --version Redis server v=5.0.5 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=fc2f09ebe3c4d851
and the latest version of RedisGraph:
marco@pc01:~$ 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) 1) "Labels added: 2" 2) "Nodes created: 6" 3) "Properties set: 6" 4) "Relationships created: 3" 5) "Query internal execution time: 1.547186 milliseconds" 127.0.0.1:6379> GRAPH.QUERY MotoGP "MATCH (r:Rider)-[:rides]->(t:Team) WHERE t.name = 'Yamaha' RETURN r.name, t.name" 1) 1) "r.name" 2) "t.name" 2) 1) 1) "Valentino Rossi" 2) "Yamaha" 3) 1) "Query internal execution time: 0.970905 milliseconds" 127.0.0.1:6379> GRAPH.QUERY MotoGP "MATCH (r:Rider)-[:rides]->(t:Team {name:'Ducati'}) RETURN count(r)" 1) 1) "count(r)" 2) 1) 1) (integer) 1 3) 1) "Query internal execution time: 0.518645 milliseconds" 127.0.0.1:6379>
Running the following redisgraph-go example:
package main import ( "github.com/gomodule/redigo/redis" rg "github.com/redislabs/redisgraph-go" ) func main() { conn, _ := redis.Dial("tcp", "0.0.0.0:6379") defer conn.Close()ì graph := rg.Graph{}.New("social", conn) 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, v.purpose, c.name` rs, _ := graph.Query(query) rs.PrettyPrint() }
I got this error :
marco@pc01:~/RedisGraph/redisgraph-goExample$ go run main.go # command-line-arguments ./main.go:12:21: redisgraph.Graph literal.New undefined (type redisgraph.Graph has no field or method New)
Any hints to solve it? Marco
Hi @marcoippolito, Apologise for my late response, The way to initialise a graph object is as follows: graph := rg.GraphNew("social", conn)
graph := rg.GraphNew("social", conn)
I've updated the README.
In Ubuntu 18.04.01 Server Edition I installed redis-server:
and the latest version of RedisGraph:
Running the following redisgraph-go example:
I got this error :
Any hints to solve it? Marco