Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-24-2020 02:08 AM
Hi. Im new to neo. I am struggling with the logic using for each. I have two queries that I want two merge.
First:
CALL spatial.withinDistance('hikes',{lat:60.4274, lon:5.3397}, 10)
yield node, distance
return id(node), distance, node.gpx_name limit 10
which returns something like:
Now, what I want to do is to apply this cypher query:
MATCH (n:hike_data {gpx_name:"dde1b329-99f0-4582-a255-f4f6effb0389.gpx"})
with n.coors_list as list
with apoc.convert.fromJsonList(list) as clean
return clean[0][0] as lat_s, clean[0][1] as lon_s, clean[-1][0] as lat_e, clean[-1][1] as lon_e
Currently im debugging this query:
yield node, distance
FOREACH (record IN node.gpx_name |
MATCH (n:hike_data {gpx_name:record})
WITH n.coors_list as listD
WITH apoc.convert.fromJsonList(list) as clean)
RETURN clean[0][0] as lat_s, clean[0][1] as lon_s, clean[-1][0] as lat_e, clean[-1][1] as lon_e
Could you help ?
Thank you
01-24-2020 02:55 AM
What error messages are you getting? Or what unexpected output?
01-24-2020 03:10 AM
I have rewritten the query to:
CALL spatial.withinDistance('hikes', {lat:60.4274, lon:5.3397}, 10)
yield node, distance
UNWIND node.gpx_name as file_name
MATCH (n:hike_data {gpx_name:file_name})
with n.coors_list as list, file_name, distance
with apoc.convert.fromJsonList(list) as clean, file_name, distance
return file_name, distance, clean[0][0] as lat_s, clean[0][1] as lon_s, clean[-1][0] as lat_e, clean[-1][1] as lon_e limit 40
But its slow ant the moment.
Now Im looking for the way to optimize it.
01-24-2020 03:15 AM
Its not possible to use WITH inside FOREACH .
All the sessions of the conference are now available online