2

I am confused about the relationship between Layers and Indexes in neo4j spatial. In particular I have the following three questions: (I can give code samples on request, but its a lot of code and not really germane to the issue).

1) Its perfectly possible to use neo4j spatial without ever explicitly creating any layers, if you add an index with a spatial index provider. However, does this mean that it is implicitly creating a layer, and that I can access that layer directly through the Java API?

2) Suppose I create a Layer. Is it possible to do Cypher Queries on this layer without explicitly creating an index as well? It doesn't seem right to have to add the same node to both a Layer and a Spatial index, yet as far as I have discovered, you can only use Cypher with spatial if you explicitly create an index.

3) I have been using SpatialIndexProvider.SIMPLE_WKT_CONFIG as my index provider, however this means that I must make a property wkt and give inputs POINT(X Y), I would like to be able to tell my encoder to use, say, two properties Longitude and Lattitude. Is this possible? It seems to be possible with the Layers, but not so much with the indexes.

4

1 に答える 1

3

1) 空間インデックス プロバイダーを使用してインデックスを追加すると、実際にはレイヤーが作成されます。これは、空のデータベースから始めて空間インデックスを追加し、作成されたノードを確認することで確認できます。この関連するノードのセットは、Java または REST を使用してレイヤーを直接作成した場合に生成されるものとまったく同じです。

作成されたインデックスを一覧表示すると、2 つのインデックスが作成されていることがわかります。1つはあなたが提供した名前で、もう1つはあなたの名前で始まり、その後に非常に長い文字列が続きます。これは、一意にするためのものだと思います(私には知られていない他の目的があるかもしれません).

2) インデックスなしで Cypher クエリを実行することはできません。しかし、結局のところ、インデックスは実際には Neo4j Spatial へのエントリ ポイントにすぎず、ノードを実際にインデックスに追加する必要はありません。ノードをインデックスに追加するか、ノードをレイヤーに追加する必要があります。両方しないでください。インデックスではなくレイヤーにノードを追加することを選択した場合、Cypher クエリが機能する前に、さらに手順を実行する必要があります。(詳細については、この他の質問に対する私の回答を参照してください。)

3) SimplePointEncoder を使用するインデックスとレイヤーを作成することは完全に可能です。これを行うための REST 呼び出しは次のとおりです。

POST http://localhost:7474/db/data/index/node {"name":"test", "config":{"provider":"spatial", "geometry_type":"point", "lat":"lat", "lon":"lon"}}

次に、緯度と経度のプロパティを持つノードを作成し、それらをインデックスまたはレイヤーに追加すると、すべてが正常に機能します。

于 2014-07-11T20:19:24.470 に答える