Neo4j: Usage of parameters of type list

Viewed 131

List parameters cannot be indexed in neo4j 4. Whenever you try to take an element from a parameter of type list, this error is thrown:

Neo.DatabaseError.General.UnknownError
Did not find any type information for expression ContainerIndex(Parameter(r,Any),SignedDecimalIntegerLiteral(0))

Neo4j Version: 4.0.3

Operating System: Ubuntu 18.04.3 LTS

DB Mode: Causal Cluster

An example query to reproduce the issue is:

MATCH (user:User)
WHERE ($range[0] > user.id OR user.id > $range[1])
return user
limit 1

$range is the parameter in question with an example value [100, 200]

This error does not happen in the previous neo4j version 3.5, as we are currently migrating to neo4j 4. It happens in the neo4j browser, and through drivers. I currently use python driver 1.7.6

1 Answers

It seems that there is indeed a problem with neo4j 4, and I am glad to see that you have already submitted an issue for that.

I have found 2 workarounds (but hopefully the issue will be fixed soon):

  1. Explicitly convert the list values to the right type. For example, if the id values are integers:

    MATCH (user:User)
    WHERE TOINTEGER($range[0]) > user.id OR user.id > TOINTEGER($range[1])
    RETURN user
    LIMIT 1
    
  2. Assign the list values to variables and use the variables instead:

    WITH $range[0] AS upper, $range[1] AS lower
    MATCH (user:User)
    WHERE upper > user.id OR user.id > lower
    RETURN user
    LIMIT 1
    
Related