Neo4J Cypher data type conversion

前端 未结 3 1476
醉酒成梦
醉酒成梦 2021-02-05 16:36

I\'ve got a property quantity on our Product-nodes and am looking to do a cypher query that gives me all nodes with quantity = 20 ... prob

相关标签:
3条回答
  • 2021-02-05 16:43
    MATCH (p:Product) WHERE toInt(p.quantity) = 20;
    
    0 讨论(0)
  • 2021-02-05 16:48

    You can do it the other way round.

    MATCH (p:Product) WHERE p.quantity = str(20) RETURN p;
    

    should also work with params.

    MATCH (p:Product) WHERE p.quantity = str({quantity}) RETURN p;
    

    or even with inline property matches

    MATCH (p:Product {quantity : str({quantity})}) RETURN p;
    
    0 讨论(0)
  • 2021-02-05 17:02

    I too have been faced with that problem earlier. As far as I found out, it was not possible to do that conversion directly in cypher. I used a small Java script (using the standard Java API) to change the data types of the stored values. This is a couple of months ago though, so it might have changed with the 2.0 version.

    0 讨论(0)
提交回复
热议问题