Neo4j Spatial, relationship between indexes and layers

前端 未结 1 1335
暖寄归人
暖寄归人 2021-01-14 20:03

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, bu

相关标签:
1条回答
  • 2021-01-14 20:23

    1) Adding an index with a spatial index provider does, in fact create a layer. You can see this by starting with an empty database and adding a spatial index, and then looking at the nodes that were created. This set of related nodes is exactly what you will find is produced if you create a layer directly using Java or REST.

    If you list the indexes created, you will find that two indexes are created. One has the name that you provided, and one starts with your name followed by a terribly long string that I assume is meant to make it unique (there may be some other purposes unknown to me).

    2) You can't do Cypher queries without an index. But as it turns out, the index is actually just an entry point into Neo4j Spatial, and you don't actually have to add your nodes to the index. You should either add your nodes to the index or add your nodes to the layer. Don't do both. If you choose to add your nodes to the layer and not the index there is further step you must take before Cypher queries will work. (See my answer to this other question for details.)

    3) It's entirely possible to create an index and a layer that uses the SimplePointEncoder. The REST call to do this is

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

    You then make nodes with properties lat and lon, add them to your index or layer, and everything works just fine.

    0 讨论(0)
提交回复
热议问题