Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Index Configuration Feature to Neo4j Spatial #410

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Andy2003
Copy link
Collaborator

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 referenceRelationshipType as 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant