neo4j пространственный: шифр не возвращает результатов

У меня есть база данных городов с широчайшей и длинной информацией, и я пытаюсь заставить работать пространственный запрос. Вот что я попробовал:

1. Создайте слой

public void CreateALayer()
{
    var restClient = new RestClient(new Uri(baseUri + "/db/data/ext/SpatialPlugin/graphdb/addSimplePointLayer"));
    var request = new RestRequest(Method.POST);
    request.AddJsonBody(
        new
        {
            layer = "geom",
            lat = "lat",
            lon = "lon"
        });
    var response = restClient.Execute(request);
    Console.WriteLine(response.Content);
}

2. Присвойте id идентификатору neo4j. Установите для свойства id узлов города значение Neo4j, используя следующий запрос Cypher:

MATCH (n:City) SET n.id = id(n)

3. Добавлены узлы в индекс и слой

    var nodeIds = client.Cypher.Match("(n:City)").Return(n => n.As<City>().id).Results.ToList(); ;
    foreach (var id in nodeIds)
    {
        AddNodeToIndex(id);
        AddNodeToLayer(id);
    }

//

public void AddNodeToIndex( long nodeId)
    {
        string URINode = string.Format("{0}/db/data/node/{1}", baseUri, nodeId);
        //# Create geom index
        var restClient = new RestClient(new Uri(baseUri + "/db/data/index/node/" + indexName));
        var request = new RestRequest(Method.POST);
        request.AddJsonBody(
            new
            {
                value = "dummy",
                key = "dummy",
                uri = URINode
            });
        var response = restClient.Execute(request);
         Console.WriteLine(response.Content);
    }

//

public void AddNodeToLayer(long nodeId)
    {
        string URINode = string.Format("{0}/db/data/node/{1}", baseUri, nodeId);
        string URIAdd = string.Format("{0}/db/data/ext/SpatialPlugin/graphdb/addNodeToLayer", baseUri);

        /*string json = string.Format("{{\"layer\":\"{0}\", \"node\":\"{1}\"}}", layer, URINode);
        HTTPCommand(new Uri(URIAdd), json);*/

        var restClient = new RestClient(new Uri(URIAdd));
        var request = new RestRequest(Method.POST);
        request.AddJsonBody(
            new
            {
                layer = indexName,
                node = URINode
            });
        var response = restClient.Execute(request);
        Console.WriteLine(response.Content);
    }

Я вижу, что узлы создаются, но не уверен, что это правильно, хотя: введите описание изображения здесь

Я пытаюсь выполнить следующий запрос, и он не возвращает мне никаких строк.START n=node:geom('withinDistance:[27.97,77.58, 10000000]') RETURN n

введите описание изображения здесь

Может кто-нибудь, пожалуйста, укажите мне, что я могу упустить здесь.

РЕДАКТИРОВАТЬ 1: я вижу, что, когда я отправляю следующее сообщение

:POST /db/data/index/node {"name":"geom", "config":{"provider":"spatial", "geometry_type":"point","lat":"lat","lon":"lon"}}

Я получаю эту ошибку в журналах:

2015-12-18 04:44:38.094+0000 ERROR [o.n.k.KernelHealth]: setting TM not OK. Kernel has encountered some problem, please perform necessary action (tx recovery/restart)
java.lang.AbstractMethodError: org.neo4j.gis.spatial.indexprovider.SpatialIndexImplementation.newApplier(Z)Lorg/neo4j/kernel/impl/transaction/command/NeoCommandHandler;
    at org.neo4j.kernel.impl.api.LegacyIndexApplierLookup$Direct.newApplier(LegacyIndexApplierLookup.java:48) ~[neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.kernel.impl.api.LegacyIndexApplier.applier(LegacyIndexApplier.java:91) ~[neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.kernel.impl.api.LegacyIndexApplier.visitIndexCreateCommand(LegacyIndexApplier.java:163) ~[neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.kernel.impl.api.CommandApplierFacade.visitIndexCreateCommand(CommandApplierFacade.java:274) ~[neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.kernel.impl.index.IndexCommand$CreateCommand.handle(IndexCommand.java:314) ~[neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.kernel.impl.api.CommandApplierFacade.visit(CommandApplierFacade.java:82) ~[neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.kernel.impl.api.CommandApplierFacade.visit(CommandApplierFacade.java:45) ~[neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation.accept(PhysicalTransactionRepresentation.java:69) ~[neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.kernel.impl.api.TransactionRepresentationStoreApplier.apply(TransactionRepresentationStoreApplier.java:108) ~[neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.kernel.impl.api.TransactionRepresentationCommitProcess.applyToStore(TransactionRepresentationCommitProcess.java:107) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.kernel.impl.api.TransactionRepresentationCommitProcess.commit(TransactionRepresentationCommitProcess.java:64) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.kernel.impl.api.KernelTransactionImplementation.commit(KernelTransactionImplementation.java:502) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.kernel.impl.api.KernelTransactionImplementation.close(KernelTransactionImplementation.java:418) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.kernel.impl.index.LegacyIndexStore.getOrCreateIndexConfig(LegacyIndexStore.java:201) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.kernel.impl.index.LegacyIndexStore.getOrCreateNodeIndexConfig(LegacyIndexStore.java:63) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.kernel.impl.api.StateHandlingStatementOperations.nodeLegacyIndexCreateLazily(StateHandlingStatementOperations.java:1318) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.kernel.impl.api.OperationsFacade.nodeLegacyIndexCreateLazily(OperationsFacade.java:820) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.kernel.impl.coreapi.IndexProviderImpl.getOrCreateNodeIndex(IndexProviderImpl.java:51) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.kernel.impl.coreapi.IndexManagerImpl.forNodes(IndexManagerImpl.java:81) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.server.rest.web.DatabaseActions.createNodeIndex(DatabaseActions.java:391) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.server.rest.web.RestfulGraphDatabase.jsonCreateNodeIndex(RestfulGraphDatabase.java:834) [neo4j-desktop-2.2.3.jar:2.2.3]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_72]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.7.0_72]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.7.0_72]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.7.0_72]
    at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) [neo4j-desktop-2.2.3.jar:2.2.3]
    at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205) [neo4j-desktop-2.2.3.jar:2.2.3]
    at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139) [neo4j-desktop-2.2.3.jar:2.2.3]
    at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302) [neo4j-desktop-2.2.3.jar:2.2.3]
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) [neo4j-desktop-2.2.3.jar:2.2.3]
    at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) [neo4j-desktop-2.2.3.jar:2.2.3]
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) [neo4j-desktop-2.2.3.jar:2.2.3]
    at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) [neo4j-desktop-2.2.3.jar:2.2.3]
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542) [neo4j-desktop-2.2.3.jar:2.2.3]
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473) [neo4j-desktop-2.2.3.jar:2.2.3]
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419) [neo4j-desktop-2.2.3.jar:2.2.3]
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409) [neo4j-desktop-2.2.3.jar:2.2.3]
    at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409) [neo4j-desktop-2.2.3.jar:2.2.3]
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558) [neo4j-desktop-2.2.3.jar:2.2.3]
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733) [neo4j-desktop-2.2.3.jar:2.2.3]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:800) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1125) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1059) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.eclipse.jetty.server.Server.handle(Server.java:497) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:248) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:620) [neo4j-desktop-2.2.3.jar:2.2.3]
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:540) [neo4j-desktop-2.2.3.jar:2.2.3]
    at java.lang.Thread.run(Unknown Source) [na:1.7.0_72]

Поскольку я не эксперт по Java, мне не интересно знать, пропустил ли я здесь какой-либо пакет.

1 ответ

Вам не нужно добавлять узел как к слою, так и к индексу. См. /questions/48086294/neo4j-spatial-withindistance-cypher-zapros-vozvraschaet-pustoj-a-vyizov-rest-vozvraschaet-dannyie/48086310#48086310 для подробного объяснения, но похоже, что если вы добавите узел и к слою, и к индексу, то IndexProvider, используемый вызовом Cypher, не вернет узлы правильно.

Поэтому попробуйте добавить только узлы в индекс (используя /db/data/index/node/geom ОТДЫХ вызов) а не /addNodeToLayer и это должно работать.

Другие вопросы по тегам