Parameters Issue


I am not sure I fully understand how parameters can be provided using JSON, but I have encountered an issue I can’t solve. Using python and the python RedisGraph module:

This is an exact paste from the example given:

import redis
from redisgraph import Node, Edge, Graph, Path

r = redis.Redis(host='localhost', port=6379)

redis_graph = Graph('social', r)

john = Node(label='person', properties={'name': 'John Doe', 'age': 33, 'gender': 'male', 'status': 'single'})

japan = Node(label='country', properties={'name': 'Japan'})

edge = Edge(john, 'visited', japan, properties={'purpose': 'pleasure'})


query = """MATCH (p:person)-[v:visited {purpose:"pleasure"}]->(c:country)
		   RETURN, p.age, v.purpose,"""

result = redis_graph.query(query)

# Print resultset

# Use parameters
params = {'purpose':"pleasure"}
query = """MATCH (p:person)-[v:visited {purpose:$purpose}]->(c:country)
		   RETURN, p.age, v.purpose,"""

result = redis_graph.query(query, params)

# Print resultset

Focus is on:

params = {'purpose':"pleasure"}
query = """MATCH (p:person)-[v:visited {purpose:$purpose}]->(c:country)
		   RETURN, p.age, v.purpose,"""
result = redis_graph.query(query, params)

Works fine for me, but when I try to run this slightly modified code:

params = {'params':{'purpose':"pleasure"}}
query = """MATCH (p:person)-[v:visited {$params}]->(c:country)
		   RETURN, p.age, v.purpose,"""

result = redis_graph.query(query, params)

It trows and error:

ResponseError                             Traceback (most recent call last)
<ipython-input-44-eafe4fde3be8> in <module>
      4 		   RETURN, p.age, v.purpose,"""
----> 6 result = redis_graph.query(query, params)
      8 # Print resultset

~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\redisgraph\ in query(self, q, params)
    128         result_set = None
--> 130         response = self.redis_con.execute_command("GRAPH.QUERY",, q, "--compact")
    131         return QueryResult(self, response)

~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\redis\ in execute_command(self, *args, **options)
    899         try:
    900             conn.send_command(*args)
--> 901             return self.parse_response(conn, command_name, **options)
    902         except (ConnectionError, TimeoutError) as e:
    903             conn.disconnect()

~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\redis\ in parse_response(self, connection, command_name, **options)
    913         "Parses a response from the Redis server"
    914         try:
--> 915             response = connection.read_response()
    916         except ResponseError:
    917             if EMPTY_RESPONSE in options:

~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\redis\ in read_response(self)
    755         if isinstance(response, ResponseError):
--> 756             raise response
    757         return response

ResponseError: errMsg: Invalid input 'a': expected PROFILE line: 1, column: 2, offset: 1 errCtx: params={'purpose': 'pleasure'} MATCH (p:person)-[v:visited {$params}]->(c:cou... errCtxOffset: 1

Is this an unsupported use case or there is a bug in the module? As far as I understand its a normal use case in Cypher. I would idealy want to use it when setting properties with the SET clause.

The redisgraph-py client doesn’t accept full JSON as its parameter argument; it simply expects a dictionary of key-value parameter pairs.

Going through the Cypher Docs of Neo4j I see that there is the ability to use nested dictionaries, is that not supported in RedisGraph?

One of the examples in the docs:

### 2.6.5. Create node with properties


  "props" : {
    "name" : "Andy",
    "position" : "Developer"


CREATE ($props)

Maps are not supported as a type (see, so AFAIK the answer is no.

After reading on maps in the Neo4j docs, I am not sure if this counts towards mappings though? It seems odd that they would implement a single level dictionaries but skip nested ones for parameter inputs.

Confirmed: The map data type, isn’t supported. This is a mapping case.

Maps are planned to be part of the next version 2.4.
You might want to follow issues on github.