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.
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.