cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Force Data Type as Float not String

keithave
Node Clone

Greetings,

Apologies if this is captured elsewhere, please redirect me.
Using Neo4j Community 3.5.6

I have input form fields in my app that capture separate, decimal longitude and latitude values...

<input type="number" min="-180" max="180" step=.000001 value="" />

The query I'm using to post the data is this...

Create(bry:Brewery {latitude: $latParam, longitude: $lngParam, address: $formatted_addressParam})

I would expect Neo4j to capture the lat lon data type as a float? but instead these are being posted as a string. How do I

  1. make it so these are posted as a float in the posting process
  2. convert all of the existing lat lon string data types to float

Many Thanks,

keith

1 ACCEPTED SOLUTION

Hello @keithave

You should have a look at toFloat() function:

CREATE (bry:Brewery {latitude: toFloat($latParam), longitude: toFloat($lngParam), address: $formatted_addressParam})
MATCH (bry:Brewery)
SET bry.latitude = toFloat(bry.latitude), bry.longitude = toFloat(bry.longitude)

Regards,
Cobra

View solution in original post

4 REPLIES 4

Hello @keithave

You should have a look at toFloat() function:

CREATE (bry:Brewery {latitude: toFloat($latParam), longitude: toFloat($lngParam), address: $formatted_addressParam})
MATCH (bry:Brewery)
SET bry.latitude = toFloat(bry.latitude), bry.longitude = toFloat(bry.longitude)

Regards,
Cobra

Ah ok, thank you Cobra, so I can specify toFloat in the Create statement. The create statement forcing this data type of float doesn't seem to be documented anywhere? Or is there documentation for this?

I gave the link to the doc of toFloat but there is only that

You bet, yea I saw that thank you, helpful for converting, but not very helpful for establishing a data type on creation. I am very thankful for 'tribal knowledge' discussions like this since Neo4j has many gaps in documenting practices like this.