SDN doesn't appear to delete nodes from a spatial index

88 views Asked by At

Can someone please help me understand how spatial indexes are supposed to work in Spring-Data-Neo4j?

I've created a simple index:

@NodeEntity
class Junction {
    @GraphId Long id;
    @Indexed(indexType = IndexType.POINT, indexName = "Location") String wkt;

    void setPosition(double longitude, double latitude) {
        this.wkt = String.format("POINT(%f %f)",longitude, latitude).replace(",",".");
    }
}

This appears to work - when I persist Junctions for which I have set a position, they appear to be added to a spatial index. (When I 'match (m) return m' from the Neo4j web console, I see that there is a node added to the spacial root with an 'id' property that matches the node added).

However, when I remove the node I added with the repository's delete, it doesn't automatically remove the node from the spacial index root.

Do I have to do something manual to get the node removed from the spatial index, or is this a feature?

Here's what the Neo4j database looks like before and after the deletion of the added junction:

Before:

Node[0]
        Labels: [ReferenceNode]
        Relationships
                0 -[LAYER]-> 1
        Properties: [[name, spatial_root]]
Node[1]
        Labels: []
        Relationships
                1 -[RTREE_ROOT]-> 2
                1 -[RTREE_METADATA]-> 3
                0 -[LAYER]-> 1
        Properties: [[layer, junctionLocations], [ctime, 1416295060307], [geomencoder, org.neo4j.gis.spatial.WKTGeometryEncoder], [layer_class, org.neo4j.gis.spatial.EditableLayerImpl], [geomencoder_config, wkt]]
Node[2]
        Labels: []
        Relationships
                1 -[RTREE_ROOT]-> 2
                2 -[RTREE_REFERENCE]-> 5
        Properties: [[bbox, [100.0, 100.0, 100.0, 100.0]]]
Node[3]
        Labels: []
        Relationships
                1 -[RTREE_METADATA]-> 3
        Properties: [[maxNodeReferences, 100], [totalGeometryCount, 1]]
Node[4]
        Labels: [Junction, _Junction]
        Relationships
        Properties: [[longitude, 100.0], [latitude, 100.0], [wkt, POINT(100.000000 100.000000)]]
Node[5]
        Labels: []
        Relationships
                2 -[RTREE_REFERENCE]-> 5
        Properties: [[wkt, POINT (100 100)], [id, 4], [gtype, 1], [bbox, [100.0, 100.0, 100.0, 100.0]]]

After:

Node[0]
        Labels: [ReferenceNode]
        Relationships
                0 -[LAYER]-> 1
        Properties: [[name, spatial_root]]
Node[1]
        Labels: []
        Relationships
                1 -[RTREE_ROOT]-> 2
                1 -[RTREE_METADATA]-> 3
                0 -[LAYER]-> 1
        Properties: [[layer, junctionLocations], [ctime, 1416295060307], [geomencoder, org.neo4j.gis.spatial.WKTGeometryEncoder], [layer_class, org.neo4j.gis.spatial.EditableLayerImpl], [geomencoder_config, wkt]]
Node[2]
        Labels: []
        Relationships
                1 -[RTREE_ROOT]-> 2
                2 -[RTREE_REFERENCE]-> 5
        Properties: [[bbox, [100.0, 100.0, 100.0, 100.0]]]
Node[3]
        Labels: []
        Relationships
                1 -[RTREE_METADATA]-> 3
        Properties: [[maxNodeReferences, 100], [totalGeometryCount, 1]]
Node[5]
        Labels: []
        Relationships
                2 -[RTREE_REFERENCE]-> 5
        Properties: [[wkt, POINT (100 100)], [id, 4], [gtype, 1], [bbox, [100.0, 100.0, 100.0, 100.0]]]

Clearly the junction has gone, but the spatial index doesn't know about the removal.

0

There are 0 answers