Optimize query for calculate distance and create relationship

Hi everyone.

To provide some context, I've implemented a system where I imported the OpenStreetMap (OSM) knowledge base of a city. Currently, I'm working on linking certain nodes based on the shortest distance between pairs of points.

To achieve this, I've been executing the following query:

MATCH (i:Inmueble)
WITH  i as inmueble
MATCH (o:OSMNode)
WITH o,inmueble, point.distance(inmueble.punto,o.location) AS distancia ORDER BY   distancia  asc LIMIT 1
CREATE (inmueble)-[:NEAREST_NODE]->(o)

The problem I am facing is that the query never finishes.

Is there a way to optimize this query using indexes or any plugin?

Thanks for helping.

Solved in this post: Accessing NEAREST node - Neo4j Graph Platform / Cypher - Neo4j Online Community