2016-06-15 11 views
2

Ich versuche eine räumliche Datenbank mit neo4j 3.0.2 und neo4j-spatial für 3.0.2 zu erstellen. Ich habe das Plugin installiert und ich habe überprüft, dass das Plugin mit cURL läuft curl -v http://neo4j:[email protected]:7474/db/data/ die Ausgänge folgenden:Neo4j Spatial 3.0.2: Kein Indexanbieter 'spatial' gefunden

{ 
    "extensions" : { 
    "SpatialPlugin" : { 
     "addSimplePointLayer" : "http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addSimplePointLayer", 
     "addNodesToLayer" : "http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addNodesToLayer", 
     "findClosestGeometries" : "http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/findClosestGeometries", 
     "addGeometryWKTToLayer" : "http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addGeometryWKTToLayer", 
     "findGeometriesWithinDistance" : "http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/findGeometriesWithinDistance", 
     "addEditableLayer" : "http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addEditableLayer", 
     "addCQLDynamicLayer" : "http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addCQLDynamicLayer", 
     "addNodeToLayer" : "http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addNodeToLayer", 
     "getLayer" : "http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/getLayer", 
     "findGeometriesInBBox" : "http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/findGeometriesInBBox", 
     "updateGeometryFromWKT" : "http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/updateGeometryFromWKT", 
     "findGeometriesIntersectingBBox" : "http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/findGeometriesIntersectingBBox" 
    } 
    }, 
    "node" : "http://localhost:7474/db/data/node", 
    "relationship" : "http://localhost:7474/db/data/relationship", 
    "node_index" : "http://localhost:7474/db/data/index/node", 
    "relationship_index" : "http://localhost:7474/db/data/index/relationship", 
    "extensions_info" : "http://localhost:7474/db/data/ext", 
    "relationship_types" : "http://localhost:7474/db/data/relationship/types", 
    "batch" : "http://localhost:7474/db/data/batch", 
    "cypher" : "http://localhost:7474/db/data/cypher", 
    "indexes" : "http://localhost:7474/db/data/schema/index", 
    "constraints" : "http://localhost:7474/db/data/schema/constraint", 
    "transaction" : "http://localhost:7474/db/data/transaction", 
    "node_labels" : "http://localhost:7474/db/data/labels", 
    "neo4j_version" : "3.0.2" 
* Connection #0 to host localhost left intact 
}* Closing connection #0 

Jetzt kann ich ein neues simplePointLayer erstellen:

// define entity manager 
$client = $this->get('neo4j.spatial_manager')->getClient(); 



// 1. Create a pointlayer 
$request = $client->request('POST', 
    '/db/data/ext/SpatialPlugin/graphdb/addSimplePointLayer', 
    [ 
     'json' => [ 
      'layer' => 'geom', 
      'lat' => 'lat', 
      'lon' => 'lon', 
     ], 
    ] 
); 

var_dump($request); 

Dies schafft den räumlichen Wurzelknoten mit der rTree. Aber wenn ich will jetzt einen räumlichen Index erstellen mit folgenden:

// 2. Create a spatial index 
$request = $client->request('POST', 
    '/db/data/index/node/', 
    [ 
     'json' => [ 
      'name' => 'geom', 
      'config' => [ 
       'provider' => 'spatial', 
       'geometry_type' => 'point', 
       'lat' => 'lat', 
       'lon' => 'lon', 
      ], 
     ], 
    ] 
); 

var_dump($request); 

ich mit der Fehlermeldung konfrontiert werde:

"message" : "No index provider 'spatial' found. 

Was mache ich falsch? Ich habe viele Foren und so weiter überprüft, aber die Antwort scheint immer zu sein, das räumliche Plugin zu installieren, das ich habe und es scheint, entsprechend der ersten Ausgabe zu arbeiten.

EDIT 15.06.2016

Was seltsam ist, dass ich Knoten zum RTree hinzufügen:

// Create a node with spatial data 
    $json = [ 
     'team' => 'REDBLUE', 
     'name' => 'TEST', 
     'lat' => 25.121075, 
     'lon' => 89.990630, 
    ]; 
    $response = $client->request('POST', 
     '/db/data/node', 
     [ 
      'json' => $json 
     ] 
    ); 

    $node = json_decode($response->getBody(), true)['self']; 

    // Add the node to the layer 
    $response = $client->request('POST', 
     '/db/data/ext/SpatialPlugin/graphdb/addNodeToLayer', 
     [ 
      'json' => [ 
       'layer' => 'geom', 
       'node' => $node, 
      ], 
     ] 
    ); 

    $data = json_decode($response->getBody(), true); 

    var_dump($data); 

Und ich die Knoten durch REST abfragen können:

$request = $client->request('POST', 
     '/db/data/ext/SpatialPlugin/graphdb/findGeometriesWithinDistance', 
     [ 
      'json' => [ 
       'layer' => 'geom', 
       'pointX' => 89.99506, 
       'pointY' => 25.121260, 
       'distanceInKm' => 10, 
      ], 
     ] 
    ); 

$data = json_decode($request->getBody(), true); 

var_dump($data); 

Aber Warum lässt es mich nicht einen Index erstellen? Oder macht es die Indizierung automatisch? Und wenn ja, wie kann ich mit CYPHER (in der Webkonsole zum Beispiel) abfragen?

Jede Hilfe wäre willkommen! Prost

Antwort

1

Der Indexanbieter wurde entfernt (damals war es das einzige Mittel, um Cypher zu integrieren), zugunsten von benutzerdefinierten Prozeduren für Spatial.

sehen: https://github.com/neo4j-contrib/spatial/blob/master/src/test/java/org/neo4j/gis/spatial/procedures/SpatialProceduresTest.java#L113

Da es sich um eine neue Hauptversion (für 3.0) fanden wir es sinnvoll, den Indexanbieter zu entfernen.

+1

Danke für diese wichtige Information! Wie genau mache ich räumliche Abfragen mit Cypher? Wenn ich versuche 'CALL spatial.withinInDistance ('geom', {pointX: 89.99506, pointY: 25.121260}, 100)' Ich bekomme den Fehler: 'Fehler beim Aufruf der Prozedur' spatial.withinDistance': Verursacht von: java.lang.NoClassDefFoundError : org/neo4j/cypher/internal/compiler/v3_0/commands/expressions/GeographicPoint' – Joran

+1

Derselbe Fehler tritt auch auf, wenn alles mit den Aufrufbefehlen unter Verwendung der Standardwerte erstellt wird: 'CALL spatial.addPointLayer ('geom')' then ' create (n: Tile {name: 'test', latitude: 47.99, longitude: 7.886}) 'und schließlich:' match (t: Tile) mit t call space.addNode ('geom', t) YIELD-Knotenrückgabezähler (*) '. Wenn ich dann abfrage mit: 'CALL spatial.withinDistance ('geom', {latitude: 47.60, longitude: 7.7}, 100)' der gleiche Fehler erscheint. – Joran