I'm migrating to spring-data-neo4j-rest v3.3.0 from 3.1.1. What I found after everything was compiling and running ok is that I get an error when saving an entity with a spatial property in it (wkt
) which is supposed to be indexed by the LocationIndex
index.
The error I get is:
{
"message": "NODE[30127] has no property with propertyKey=\"wkt\".",
"exception": "NotFoundException",
"fullname": "org.neo4j.graphdb.NotFoundException",
"stacktrace": [
"org.neo4j.kernel.impl.core.NodeProxy.getProperty(NodeProxy.java:378)",
"org.neo4j.gis.spatial.WKTGeometryEncoder.decodeGeometry(WKTGeometryEncoder.java:44)",
"org.neo4j.gis.spatial.indexprovider.LayerNodeIndex.add(LayerNodeIndex.java:126)",
"org.neo4j.gis.spatial.indexprovider.LayerNodeIndex.add(LayerNodeIndex.java:41)",
"org.neo4j.server.rest.web.DatabaseActions.addToNodeIndex(DatabaseActions.java:708)",
"org.neo4j.server.rest.web.RestfulGraphDatabase.addToNodeIndex(RestfulGraphDatabase.java:1058)",
"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)"
],
"cause": {
"message": "NODE[30127] has no property with propertyKeyId=20.",
"exception": "PropertyNotFoundException",
"fullname": "org.neo4j.kernel.api.exceptions.PropertyNotFoundException",
"stacktrace": [
"org.neo4j.kernel.api.properties.NoProperty.value(NoProperty.java:93)",
"org.neo4j.kernel.impl.core.NodeProxy.getProperty(NodeProxy.java:374)",
"org.neo4j.gis.spatial.WKTGeometryEncoder.decodeGeometry(WKTGeometryEncoder.java:44)",
"org.neo4j.gis.spatial.indexprovider.LayerNodeIndex.add(LayerNodeIndex.java:126)",
"org.neo4j.gis.spatial.indexprovider.LayerNodeIndex.add(LayerNodeIndex.java:41)",
"org.neo4j.server.rest.web.DatabaseActions.addToNodeIndex(DatabaseActions.java:708)",
"org.neo4j.server.rest.web.RestfulGraphDatabase.addToNodeIndex(RestfulGraphDatabase.java:1058)",
"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)"
]
}
}
The object does have that property in it before calling the addToIndex
method and so I saw inspecting the properties:
@Override
public <T extends PropertyContainer> void addToIndex(T entity, RestIndex index, String key, Object value) {
final RestEntity restEntity = (RestEntity) entity; //at this point "wkt":"POINT(-12.130000 51.120000)"
String uri = restEntity.getUri();
if (value instanceof ValueContext) {
value = ((ValueContext)value).getCorrectValue();
}
final Map<String, Object> data = map("key", key, "value", value, "uri", uri);
final RequestResult result = getRestRequest().post(indexPath(index, null, null), data);
if (result.statusOtherThan(Status.CREATED)) throw new RuntimeException(String.format("Error adding element %d %s %s to index %s", restEntity.getId(), key, value, index.getIndexName()));
}
If I undo my changes and go back to v3.1.1, hitting the same database (neo4j 2.1.1 with spatial 2.1.2 plugin), it works like charm.
May it be that the properties are not saved into the database before calling the addToIndex
method?