Neo4j Spatial, relationship between indexes and layers

耗尽温柔 提交于 2019-12-01 11:08:22
Jim Biard

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!