Neo4j Spatial index error duplicates

34 views
Skip to first unread message

Amin Abu-Taleb

unread,
Jan 30, 2015, 5:10:31 AM1/30/15
to ne...@googlegroups.com

I'm having an error when inserting in Neo4j a spatial object with Spring Data:

Caused by: java.lang.RuntimeException: Error adding element 20 wkt POINT(-0.131483 51.513861) to index LocationIndex
at org.neo4j.rest.graphdb.ExecutingRestAPI.addToIndex(ExecutingRestAPI.java:470)
at org.neo4j.rest.graphdb.RestAPIFacade.addToIndex(RestAPIFacade.java:168)
at org.neo4j.rest.graphdb.index.RestIndex.add(RestIndex.java:60)

That's basically because there was a different entry before (that doesn't exist anymore, with the same location). The uniqueness of the constraint means two different objects cannot have the same location, but if you delete the previous one, it seems to remain in the index and collides.

Is there any way of re-indexing the spatial index in neo4j? I mean, delete everything and re-index only the existing data.

Else, is it posible to delete them manually?

Thanks!

Amin Abu-Taleb

unread,
Jan 30, 2015, 6:28:54 AM1/30/15
to ne...@googlegroups.com
Hi everybody, after further investigation, I've come up with the real error: 

{
"message" : "GeometryNode not indexed with an RTree: 21",
"exception" : "RuntimeException",
"fullname" : "java.lang.RuntimeException",
"stacktrace" : [ "org.neo4j.gis.spatial.rtree.RTreeIndex.findLeafContainingGeometryNode(RTreeIndex.java:794)", "org.neo4j.gis.spatial.rtree.RTreeIndex.remove(RTreeIndex.java:111)", "org.neo4j.gis.spatial.rtree.RTreeIndex.remove(RTreeIndex.java:100)", "org.neo4j.gis.spatial.EditableLayerImpl.update(EditableLayerImpl.java:56)", "org.neo4j.gis.spatial.indexprovider.LayerNodeIndex.add(LayerNodeIndex.java:143)", "org.neo4j.gis.spatial.indexprovider.LayerNodeIndex.add(LayerNodeIndex.java:41)", "org.neo4j.server.rest.web.DatabaseActions.addToNodeIndex(DatabaseActions.java:686)", "org.neo4j.server.rest.web.RestfulGraphDatabase.addToNodeIndex(RestfulGraphDatabase.java:1022)", "java.lang.reflect.Method.invoke(Method.java:606)", "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)", "java.lang.Thread.run(Thread.java:745)" ]
}

Can anybody shed some light on this? What does this mean and why do I have this error only with some few nodes? 

Amin Abu-Taleb

unread,
Jan 30, 2015, 7:31:14 AM1/30/15
to ne...@googlegroups.com
Finally found the cause but I can't believe it: 

From the neo4j github repo I see this: 
https://github.com/neo4j/neo4j/blob/2.1-maint/community/server/src/main/java/org/neo4j/server/rest/web/RestfulGraphDatabase.java#L205

private long extractNodeId( String uri ) throws BadInputException
{
try
{
return Long.parseLong( uri.substring( uri.lastIndexOf( "/" ) + 1 ) );
}
catch ( NumberFormatException | NullPointerException ex )
{
throw new BadInputException( ex );
}
}

It assumes that the index node is the node with the next id number. Because of the ID recycling in my DB, node 21 (in this particular case) has become a non-index node, which makes impossible for me to index nodes with recycled IDs. 

I'd really appreciate someone's help in this. What should I do? Is there any alternative to rebuilding the DB from the scratch?

Amin Abu-Taleb

--
You received this message because you are subscribed to a topic in the Google Groups "Neo4j" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/neo4j/lKY4_RgRoig/unsubscribe.
To unsubscribe from this group and all its topics, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages