1

有人可以帮我理解空间索引在 Spring-Data-Neo4j 中应该如何工作吗?

我创建了一个简单的索引:

@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(",",".");
    }
}

这似乎可行 - 当我坚持已设置位置的连接点时,它们似乎已添加到空间索引中。(当我从 Neo4j Web 控制台“匹配(m)返回 m”时,我看到空间根中添加了一个节点,其“id”属性与添加的节点匹配)。

但是,当我删除使用存储库的delete添加的节点时,它不会自动从空间索引根中删除该节点。

我是否必须手动操作才能从空间索引中删除节点,或者这是一个功能?

这是 Neo4j 数据库在删除添加的联结之前和之后的样子:

前:

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]]]

后:

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]]]

很明显,路口已经消失,但空间索引不知道移除。

4

0 回答 0