Neo4J Cypher数据类型转换 [英] Neo4J Cypher data type conversion
本文介绍了Neo4J Cypher数据类型转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Product
节点上有一个属性quantity
,并且正在寻找一个密码查询,该查询可以为我提供所有具有quantity = 20
的节点...问题是数量作为字符串存储在neo4j中.有没有办法在密码查询中将属性转换为整数?
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
... problem is that quantity is stored as a string in neo4j. Is there a way to cast the property to integer in the cypher query?
// This fails to find the required nodes
MATCH (p:Product) WHERE p.quantity = 20;
// This finds them
MATCH (p:Product) WHERE p.quantity = "20";
// I would like to do this
MATCH (p:Product) WHERE INT(p.quantity) = 20;
PS:这是一个非常简化的用例,我们实际上没有产品和数量,而只是面对现有的neo4j数据,该数据具有作为字符串存储的整数值,我们希望对此进行一些匹配字符串
推荐答案
您可以反过来做.
MATCH (p:Product) WHERE p.quantity = str(20) RETURN p;
还应该使用params.
should also work with params.
MATCH (p:Product) WHERE p.quantity = str({quantity}) RETURN p;
甚至与内联属性匹配
MATCH (p:Product {quantity : str({quantity})}) RETURN p;
这篇关于Neo4J Cypher数据类型转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文