如何在 Neo4J 空间中创建 SimplePointLayer?
How do I create a SimplePointLayer in Neo4J spatial?
我在堆栈中看到了一些展示如何创建 simplePointLayer 的帖子。但是,这个过程对我来说失败了。
我正在使用 Neo4J 版本 3.0.2 和空间插件版本 3.0.2.
我已经here, here, and 。
这些页面中的每一个都包含用于创建 SimplePointLayer 的相同指令集,如下所示。
这一步对我来说很好用:
POST /db/data/ext/SpatialPlugin/graphdb/addSimplePointLayer HTTP/1.1
Host: localhost:7474
Accept: application/json
Content-Type: application/json
Cache-Control: no-cache
{
"layer" : "geom",
"lat" : "lat",
"lon" : "lon"
}
我不确定在哪里可以看到层列表,但响应是 200,所以我假设这里的一切都按预期工作。
以下步骤是我卡住的地方:
POST /db/data/index/node/ HTTP/1.1
Host: localhost:7474
Accept: application/json
Content-Type: application/json
Cache-Control: no-cache
{
"name" : "geom",
"config" : {
"provider" : "spatial",
"geometry_type" : "point",
"lat" : "lat",
"lon" : "lon"
}
}
我在文件 tmp.json 中有上面的 json 并且我 运行
cat tmp.json | http :7474/db/data/index/node
这会生成以下消息:
HTTP/1.1 400 Bad Request
Access-Control-Allow-Origin: *
Content-Length: 6887
Content-Type: application/json; charset=UTF-8
Date: Wed, 06 Jul 2016 18:14:18 GMT
Server: Jetty(9.2.9.v20150224)
{
"errors": [
{
"code": "Neo.DatabaseError.General.UnknownError",
"message": "No index provider 'spatial' found. Maybe the intended provider (or one more of its dependencies) aren't on the classpath or it failed to load.",
"stackTrace": "java.lang.IllegalArgumentException: No index provider 'spatial' found. Maybe the intended provider (or one more of its dependencies) aren't on the classpath or it failed to load.\n\tat org.neo4j.kernel.NeoStoreDataSource.apply(NeoStoreDataSource.java:386)\n\tat org.neo4j.kernel.NeoStoreDataSource.apply(NeoStoreDataSource.java:378)\n\tat org.neo4j.kernel.impl.index.LegacyIndexStore.findIndexConfig(LegacyIndexStore.java:105)\n\tat org.neo4j.kernel.impl.index.LegacyIndexStore.getOrCreateIndexConfig(LegacyIndexStore.java:171)\n\tat org.neo4j.kernel.impl.index.LegacyIndexStore.getOrCreateNodeIndexConfig(LegacyIndexStore.java:64)\n\tat org.neo4j.kernel.impl.api.StateHandlingStatementOperations.nodeLegacyIndexCreateLazily(StateHandlingStatementOperations.java:1475)\n\tat org.neo4j.kernel.impl.api.OperationsFacade.nodeLegacyIndexCreateLazily(OperationsFacade.java:1195)\n\tat org.neo4j.kernel.impl.coreapi.IndexProviderImpl.getOrCreateNodeIndex(IndexProviderImpl.java:52)\n\tat org.neo4j.kernel.impl.coreapi.IndexManagerImpl.forNodes(IndexManagerImpl.java:81)\n\tat org.neo4j.server.rest.web.DatabaseActions.createNodeIndex(DatabaseActions.java:381)\n\tat org.neo4j.server.rest.web.RestfulGraphDatabase.jsonCreateNodeIndex(RestfulGraphDatabase.java:845)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat com.sun.jersey.spi.container.JavaMethodInvokerFactory.invoke(JavaMethodInvokerFactory.java:60)\n\tat com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)\n\tat com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)\n\tat org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)\n\tat com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)\n\tat com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)\n\tat com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)\n\tat com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)\n\tat com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)\n\tat com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)\n\tat com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558)\n\tat com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:790)\n\tat org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)\n\tat org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)\n\tat org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)\n\tat org.eclipse.jetty.server.Server.handle(Server.java:497)\n\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)\n\tat org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)\n\tat org.eclipse.jetty.io.AbstractConnection.run(AbstractConnection.java:540)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.run(QueuedThreadPool.java:555)\n\tat java.lang.Thread.run(Thread.java:745)\n"
}
],
"exception": "IllegalArgumentException",
"fullname": "java.lang.IllegalArgumentException",
"message": "No index provider 'spatial' found. Maybe the intended provider (or one more of its dependencies) aren't on the classpath or it failed to load.",
"stackTrace": [
"org.neo4j.kernel.NeoStoreDataSource.apply(NeoStoreDataSource.java:386)",
"org.neo4j.kernel.NeoStoreDataSource.apply(NeoStoreDataSource.java:378)",
"org.neo4j.kernel.impl.index.LegacyIndexStore.findIndexConfig(LegacyIndexStore.java:105)",
"org.neo4j.kernel.impl.index.LegacyIndexStore.getOrCreateIndexConfig(LegacyIndexStore.java:171)",
"org.neo4j.kernel.impl.index.LegacyIndexStore.getOrCreateNodeIndexConfig(LegacyIndexStore.java:64)",
"org.neo4j.kernel.impl.api.StateHandlingStatementOperations.nodeLegacyIndexCreateLazily(StateHandlingStatementOperations.java:1475)",
"org.neo4j.kernel.impl.api.OperationsFacade.nodeLegacyIndexCreateLazily(OperationsFacade.java:1195)",
"org.neo4j.kernel.impl.coreapi.IndexProviderImpl.getOrCreateNodeIndex(IndexProviderImpl.java:52)",
"org.neo4j.kernel.impl.coreapi.IndexManagerImpl.forNodes(IndexManagerImpl.java:81)",
"org.neo4j.server.rest.web.DatabaseActions.createNodeIndex(DatabaseActions.java:381)",
"org.neo4j.server.rest.web.RestfulGraphDatabase.jsonCreateNodeIndex(RestfulGraphDatabase.java:845)",
"java.lang.reflect.Method.invoke(Method.java:498)",
"org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
"org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
"java.lang.Thread.run(Thread.java:745)"
]
}
我不确定从这里到哪里去。我假设 'provider' 是插件。我不是 JAVA 人,所以我不确定如何处理类路径。之前有没有人遇到过这个错误\知道如何处理这个问题?
随着 Neo4j 3.0 中用户定义过程的引入,空间库目前有点变化。具体来说:
程序正在成为与空间交互的推荐方式,并且
索引提供程序已从空间库中删除(导致您遇到的错误)
通过程序,您现在可以访问 Cypher 的空间功能:
创建图层
CALL spatial.addPointLayer('cities');
将所有城市添加到图层
MATCH (c:City)
WITH collect(c) AS cities
CALL spatial.addNodes('cities',cities) YIELD node
RETURN count(*)
查找距离内的城市
MATCH (c:City {name:"Berlin"}) WITH c
CALL spatial.distance('cities', c , 200) YIELD node, distance
RETURN node.name AS name, round(distance) AS dist
有关详细信息,请参阅 this。
我在堆栈中看到了一些展示如何创建 simplePointLayer 的帖子。但是,这个过程对我来说失败了。 我正在使用 Neo4J 版本 3.0.2 和空间插件版本 3.0.2.
我已经here, here, and
这些页面中的每一个都包含用于创建 SimplePointLayer 的相同指令集,如下所示。
这一步对我来说很好用:
POST /db/data/ext/SpatialPlugin/graphdb/addSimplePointLayer HTTP/1.1
Host: localhost:7474
Accept: application/json
Content-Type: application/json
Cache-Control: no-cache
{
"layer" : "geom",
"lat" : "lat",
"lon" : "lon"
}
我不确定在哪里可以看到层列表,但响应是 200,所以我假设这里的一切都按预期工作。
以下步骤是我卡住的地方:
POST /db/data/index/node/ HTTP/1.1
Host: localhost:7474
Accept: application/json
Content-Type: application/json
Cache-Control: no-cache
{
"name" : "geom",
"config" : {
"provider" : "spatial",
"geometry_type" : "point",
"lat" : "lat",
"lon" : "lon"
}
}
我在文件 tmp.json 中有上面的 json 并且我 运行
cat tmp.json | http :7474/db/data/index/node
这会生成以下消息:
HTTP/1.1 400 Bad Request
Access-Control-Allow-Origin: *
Content-Length: 6887
Content-Type: application/json; charset=UTF-8
Date: Wed, 06 Jul 2016 18:14:18 GMT
Server: Jetty(9.2.9.v20150224)
{
"errors": [
{
"code": "Neo.DatabaseError.General.UnknownError",
"message": "No index provider 'spatial' found. Maybe the intended provider (or one more of its dependencies) aren't on the classpath or it failed to load.",
"stackTrace": "java.lang.IllegalArgumentException: No index provider 'spatial' found. Maybe the intended provider (or one more of its dependencies) aren't on the classpath or it failed to load.\n\tat org.neo4j.kernel.NeoStoreDataSource.apply(NeoStoreDataSource.java:386)\n\tat org.neo4j.kernel.NeoStoreDataSource.apply(NeoStoreDataSource.java:378)\n\tat org.neo4j.kernel.impl.index.LegacyIndexStore.findIndexConfig(LegacyIndexStore.java:105)\n\tat org.neo4j.kernel.impl.index.LegacyIndexStore.getOrCreateIndexConfig(LegacyIndexStore.java:171)\n\tat org.neo4j.kernel.impl.index.LegacyIndexStore.getOrCreateNodeIndexConfig(LegacyIndexStore.java:64)\n\tat org.neo4j.kernel.impl.api.StateHandlingStatementOperations.nodeLegacyIndexCreateLazily(StateHandlingStatementOperations.java:1475)\n\tat org.neo4j.kernel.impl.api.OperationsFacade.nodeLegacyIndexCreateLazily(OperationsFacade.java:1195)\n\tat org.neo4j.kernel.impl.coreapi.IndexProviderImpl.getOrCreateNodeIndex(IndexProviderImpl.java:52)\n\tat org.neo4j.kernel.impl.coreapi.IndexManagerImpl.forNodes(IndexManagerImpl.java:81)\n\tat org.neo4j.server.rest.web.DatabaseActions.createNodeIndex(DatabaseActions.java:381)\n\tat org.neo4j.server.rest.web.RestfulGraphDatabase.jsonCreateNodeIndex(RestfulGraphDatabase.java:845)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat com.sun.jersey.spi.container.JavaMethodInvokerFactory.invoke(JavaMethodInvokerFactory.java:60)\n\tat com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)\n\tat com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)\n\tat org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)\n\tat com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)\n\tat com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)\n\tat com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)\n\tat com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)\n\tat com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)\n\tat com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)\n\tat com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558)\n\tat com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:790)\n\tat org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)\n\tat org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)\n\tat org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)\n\tat org.eclipse.jetty.server.Server.handle(Server.java:497)\n\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)\n\tat org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)\n\tat org.eclipse.jetty.io.AbstractConnection.run(AbstractConnection.java:540)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.run(QueuedThreadPool.java:555)\n\tat java.lang.Thread.run(Thread.java:745)\n"
}
],
"exception": "IllegalArgumentException",
"fullname": "java.lang.IllegalArgumentException",
"message": "No index provider 'spatial' found. Maybe the intended provider (or one more of its dependencies) aren't on the classpath or it failed to load.",
"stackTrace": [
"org.neo4j.kernel.NeoStoreDataSource.apply(NeoStoreDataSource.java:386)",
"org.neo4j.kernel.NeoStoreDataSource.apply(NeoStoreDataSource.java:378)",
"org.neo4j.kernel.impl.index.LegacyIndexStore.findIndexConfig(LegacyIndexStore.java:105)",
"org.neo4j.kernel.impl.index.LegacyIndexStore.getOrCreateIndexConfig(LegacyIndexStore.java:171)",
"org.neo4j.kernel.impl.index.LegacyIndexStore.getOrCreateNodeIndexConfig(LegacyIndexStore.java:64)",
"org.neo4j.kernel.impl.api.StateHandlingStatementOperations.nodeLegacyIndexCreateLazily(StateHandlingStatementOperations.java:1475)",
"org.neo4j.kernel.impl.api.OperationsFacade.nodeLegacyIndexCreateLazily(OperationsFacade.java:1195)",
"org.neo4j.kernel.impl.coreapi.IndexProviderImpl.getOrCreateNodeIndex(IndexProviderImpl.java:52)",
"org.neo4j.kernel.impl.coreapi.IndexManagerImpl.forNodes(IndexManagerImpl.java:81)",
"org.neo4j.server.rest.web.DatabaseActions.createNodeIndex(DatabaseActions.java:381)",
"org.neo4j.server.rest.web.RestfulGraphDatabase.jsonCreateNodeIndex(RestfulGraphDatabase.java:845)",
"java.lang.reflect.Method.invoke(Method.java:498)",
"org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
"org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
"java.lang.Thread.run(Thread.java:745)"
]
}
我不确定从这里到哪里去。我假设 'provider' 是插件。我不是 JAVA 人,所以我不确定如何处理类路径。之前有没有人遇到过这个错误\知道如何处理这个问题?
随着 Neo4j 3.0 中用户定义过程的引入,空间库目前有点变化。具体来说:
程序正在成为与空间交互的推荐方式,并且
索引提供程序已从空间库中删除(导致您遇到的错误)
通过程序,您现在可以访问 Cypher 的空间功能:
创建图层
CALL spatial.addPointLayer('cities');
将所有城市添加到图层
MATCH (c:City)
WITH collect(c) AS cities
CALL spatial.addNodes('cities',cities) YIELD node
RETURN count(*)
查找距离内的城市
MATCH (c:City {name:"Berlin"}) WITH c
CALL spatial.distance('cities', c , 200) YIELD node, distance
RETURN node.name AS name, round(distance) AS dist
有关详细信息,请参阅 this。