Neo4j空间,索引与图层之间的关系 [英] Neo4j Spatial, relationship between indexes and layers

查看:99
本文介绍了Neo4j空间,索引与图层之间的关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对neo4j空间中的图层和索引之间的关系感到困惑.特别是,我有以下三个问题:(我可以根据要求提供代码示例,但是它的代码很多,与问题无关).

1)如果使用空间索引提供程序添加索引,则完全可以使用neo4j空间而无需显式创建任何层.但是,这是否意味着它隐式地创建了一个层,并且我可以直接通过Java API访问该层?

2)假设我创建了一个图层.是否可以在不显式创建索引的情况下在此层上进行Cypher查询?不必同时向图层"和空间"索引中添加相同的节点似乎是不正确的,但是据我发现,如果您明确创建索引,则只能将Cypher与空间一起使用.

3)我一直在使用SpatialIndexProvider.SIMPLE_WKT_CONFIG作为索引提供者,但这意味着我必须创建一个属性wkt并提供输入POINT(XY),我希望能够告诉编码器使用,例如,两个属性经度和纬度.这可能吗?层似乎有可能,但索引却没有.

解决方案

1)实际上,使用空间索引提供程序添加索引确实会创建一个图层.您可以通过从一个空的数据库开始并添加一个空间索引,然后查看创建的节点来查看.如果直接使用Java或REST创建一个层,则这组相关节点正是您将发现的.

如果列出创建的索引,则会发现创建了两个索引.一个具有您提供的名称,一个以您的名称开头,然后是一个我认为是要使其唯一的非常长的字符串(对于我而言,可能还有其他用途).

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"}}

然后您创建具有lat和lon属性的节点,将它们添加到索引或图层中,一切正常.

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.

这篇关于Neo4j空间,索引与图层之间的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆