Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将spring-data-neo4j与空间索引和密码一起使用?_Neo4j_Spatial_Spring Data Neo4j - Fatal编程技术网

如何将spring-data-neo4j与空间索引和密码一起使用?

如何将spring-data-neo4j与空间索引和密码一起使用?,neo4j,spatial,spring-data-neo4j,Neo4j,Spatial,Spring Data Neo4j,我想在spring-data-Neo4j框架中使用Neo4j中的空间索引。另外,我想使用cypher查询索引。数据库是嵌入式的 我不知道如何把所有的电线连接起来 对于这样的域对象 @NodeEntity class Junction { @GraphId Long id; @Indexed(indexType = IndexType.POINT, indexName = "junctionLocations") Point wkt; } SDN应该为我维护索引。看起来是这样的,

我想在spring-data-Neo4j框架中使用Neo4j中的空间索引。另外,我想使用cypher查询索引。数据库是嵌入式的

我不知道如何把所有的电线连接起来

对于这样的域对象

@NodeEntity
class Junction {
    @GraphId Long id;
    @Indexed(indexType = IndexType.POINT, indexName = "junctionLocations") Point wkt;
}
SDN应该为我维护索引。看起来是这样的,因为我可以使用存储库进行空间查询:

interface JunctionGraph extends GraphRepository<Junction>, SpatialRepository<Junction> {}
但是,我知道,要通过存储库中的@query使用cypher查询此索引,此空间索引配置将不起作用。我认为这是因为每个节点都需要手动添加到空间索引中,或者至少为节点添加一个代理。这意味着将其添加到JunctionGraph:

@Query("START n=node:junctionLocations('withinDistance:[{0}, {1}, {2}]') MATCH n-[*]->(i:Item) return i")
Collection<Item> getItemsWithin(double lat, double lon, double radius)
不起作用


有人有有效的食谱吗?这对我来说似乎有点不可思议,我不确定在SDN中进行操作的最佳方式是什么。

它可以工作,您只需在外部创建整个查询字符串并将其作为参数传递,字符串常量中的占位符不会被替换

@Query("START n=node:junctionLocations({0}) MATCH n-[*]->(i:Item) return i")
Collection<Item> getItemsWithin(String query)
你必须自己更换。使用String.format


String.formatwithinDistance:[%f,%f,%f],lat,lon,radius

作为旁白,您知道如何将索引之前添加的节点添加到索引中吗?只是重新保存节点不起作用。我无法删除和重新添加它们,因为它们已经深深嵌入到我的图表中。啊哈,明白了。没有添加它们,因为旧节点没有WKT元素。一切都好你能分享一下你在哪里导入了IndexType.POINT吗?
@Query("START n=node:junctionLocations({0}) MATCH n-[*]->(i:Item) return i")
Collection<Item> getItemsWithin(String query)