有人可以帮我理解空间索引应该如何在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(",",".");
}
}
这似乎有效 - 当我坚持我已设置位置的Junction时,它们似乎被添加到空间索引中。 (当我从Neo4j网络控制台匹配(m)返回m'时,我看到在空间根中添加了一个节点,其中包含与添加的节点匹配的“id”属性)。
但是,当我删除我使用存储库删除添加的节点时,它不会自动从空间索引根目录中删除该节点。
我是否必须手动操作以从空间索引中删除节点,或者这是一个功能?
这是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]]]
显然交汇点已经消失,但空间索引并不知道删除。