简体   繁体   中英

How can I create a primitive type to a property in neo4j using ruby?

I'm new to Neo4j and I have lots of other experience with databases / SQL.

I'm trying to create some properties with primitive types for a node. eg. amount:float so that I can properly query the data. eg.

create (a:product {id:'1', name:'widget', amount:'16'});  
MATCH (a:product) Where a.amount > 15 RETURN a;

This query doesn't return anything :(

I'm using neography for ruby. I am using Cypher for bulk loading data.

Any suggestions how I can set the primitive types for a property?

As far as type in Cypher goes, it is inferred, not explicitly declared.

amount:'16'   // '16' is a String and '16' + '5' = '165', i.e. string concatenation
amount: 16    // 16 is an integer, 16 + 5 = 21
amount: 16.0  // 16.0 is a float
etc

Your amount value is a string, either set it to an int value or a float value as above, or compare it to another string: '16' > '15' as much as 16 > 15 .

You didn't use a number when creating your data.

create (a:product {id:'1', name:'widget', amount:16});  

MATCH (a:product) Where a.amount > 15 RETURN a;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM