Neo4J Cypher 数据类型转换 [英] Neo4J Cypher data type conversion

查看:74
本文介绍了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;

也应该使用参数.

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

甚至内联属性匹配

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

这篇关于Neo4J Cypher 数据类型转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆