Neo4j Spatial,索引和层的关系 [英] Neo4j Spatial, relationship between indexes and layers

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

问题描述

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

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) 如果您添加带有空间索引提供程序的索引,则完全有可能在不显式创建任何层的情况下使用 neo4j 空间.但是,这是否意味着它隐式地创建了一个层,并且我可以通过 Java API 直接访问该层?

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) 假设我创建了一个图层.是否可以在不显式创建索引的情况下在此层上执行密码查询?必须将相同的节点添加到图层和空间索引似乎不太正确,但据我所知,如果您明确创建索引,则只能将 Cypher 与空间一起使用.

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) 我一直在使用 SpatialIndexProvider.SIMPLE_WKT_CONFIG 作为我的索引提供程序,但这意味着我必须创建一个属性 wkt 并提供输入 POINT(XY),我希望能够告诉我的编码器使用,例如,两个属性经度和纬度.这可能吗?层似乎是可能的,但索引则不然.

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

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) 没有索引就不能进行 Cypher 查询.但事实证明,索引实际上只是 Neo4j Spatial 的入口点,您实际上不必将节点添加到索引中.您应该将节点添加到索引或将节点添加到层.不要两者都做.如果您选择将节点添加到层而不是索引,则必须采取进一步的步骤才能使 Cypher 查询起作用.(见我对这个其他问题的回答 了解详情.)

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) 完全有可能创建一个使用 SimplePointEncoder 的索引和一个层.执行此操作的 REST 调用是

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

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

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

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

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