spatial
spatial copied to clipboard
Add Index Configuration Feature to Neo4j Spatial
Overview
This PR introduces a new feature allowing users to configure spatial indexes in Neo4j Spatial. Previously, it was not possible to index the same Node with two separate indexes. This update addresses that limitation by introducing customizable index configurations, including a new referenceRelationshipType option.
Key Changes:
Index Configuration Options:
- Added support for custom configuration of spatial indexes.
- Users can now specify all the config parameters available for an index
- Add
referenceRelationshipTypeas config parameter to the pRTreeIndex
Code Enhancements:
- Modified index creation logic to incorporate configuration options.
- Ensured backward compatibility with default configurations.
Tests and Validation:
- Added unit tests for the new configuration options.
- Ensured all existing tests pass.
Usage:
// create 1st index
CALL spatial.addLayer('point1','NativePoint','point1:point1BB', '{"referenceRelationshipType": "RTREE_P1_TYPE"}')
// create 2nd index
CALL spatial.addLayer('point2','NativePoint','point2:point2BB', '{"referenceRelationshipType": "RTREE_P2_TYPE"}')
Now you can add the same Node to both indexes:
UNWIND range(1,$count) as i
CREATE (n:Point {
id: i,
point1: point( { latitude: 56.0, longitude: 12.0 } ),
point2: point( { latitude: 57.0, longitude: 13.0 } )
})
MATCH (p:Point)
WITH (count(p) / 10) AS pages, collect(p) AS nodes
UNWIND range(0, pages) AS i CALL {
WITH i, nodes
CALL spatial.addNodes('point1', nodes[(i * 10)..((i + 1) * 10)]) YIELD count
RETURN count AS count
} IN TRANSACTIONS OF 1 ROWS
RETURN sum(count) AS count
MATCH (p:Point)
WITH (count(p) / 10) AS pages, collect(p) AS nodes
UNWIND range(0, pages) AS i CALL {
WITH i, nodes
CALL spatial.addNodes('point2', nodes[(i * 10)..((i + 1) * 10)]) YIELD count
RETURN count AS count
} IN TRANSACTIONS OF 1 ROWS
RETURN sum(count) AS count