neo4jspring-data-neo4jspring-data-neo4j-4neo4j-ogm

how to convert string values of an array to integer in neo4j?


I am not being able to convert the string value of an array (e.g. score:["1", "0"]) into an Integer in Neo4j.

I have tried:

MATCH (n:Game {game_id:"1"})
RETURN toInteger(n.score[0])

This query returns a null value as a result.


Solution

  • I tried your query, but it works fine for me. This is my example data set:

    CREATE (n:Game {game_id:"1", score:["1","0"]})
    

    This is the query:

    MATCH (n:Game {game_id:"1"})
    RETURN toInteger(n.score[0])
    

    And it returns:

    ╒═══════════════════════╕
    │"toInteger(n.score[0])"│
    ╞═══════════════════════╡
    │1                      │
    └───────────────────────┘