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
Neo4J、SDN和运行Cypher空间查询_Neo4j_Cypher_Spring Data Neo4j - Fatal编程技术网

Neo4J、SDN和运行Cypher空间查询

Neo4J、SDN和运行Cypher空间查询,neo4j,cypher,spring-data-neo4j,Neo4j,Cypher,Spring Data Neo4j,我是Neo4J的新手,我正在尝试为基于时空的高可用性查询建立一个概念证明 我有两个独立的Neo4J企业服务器和一个运行嵌入式HA Neo4J服务器的Java应用程序 一切都很容易设置,基本查询也很容易设置和高效。另外,按照预期执行从Neo4J派生的查询 我很难理解的是如何使用SDN结合任何其他where子句进行空间查询。作为一个简单的例子,我如何编写“查找所有用户X在lat/lon的Y英里范围内的位置”。因为SpatialRepository不是常规Spring Repository类树的一部分

我是Neo4J的新手,我正在尝试为基于时空的高可用性查询建立一个概念证明

我有两个独立的Neo4J企业服务器和一个运行嵌入式HA Neo4J服务器的Java应用程序

一切都很容易设置,基本查询也很容易设置和高效。另外,按照预期执行从Neo4J派生的查询

我很难理解的是如何使用SDN结合任何其他where子句进行空间查询。作为一个简单的例子,我如何编写“查找所有用户X在lat/lon的Y英里范围内的位置”。因为SpatialRepository不是常规Spring Repository类树的一部分,我不相信有任何可以使用的命名约定,我执行空间查询然后过滤结果的意图是什么

我已经将代码追踪到了一个LegacyIndexSearcher(它的名字让我害怕!),但我看不到任何扩展搜索的机制。我还研究了on-GitHub,它可以提供一种手动机制来对索引执行查询,只是我认为可能有两个索引在起作用

如果我了解如何构造可以在@query注释中使用的密码查询,这可能会有所帮助。虽然我已经能够使用控制台执行简单的REST查询,但使用:

:POST /db/data/ext/SpatialPlugin/graphdb/findGeometriesWithinDistance { "layer":"location", "pointX":0.0, "pointY":51.526256, "distanceInKm":100 } 因此,也许这应该是我尝试的查询的正确格式:

start n=node:GeoTemporalThing('withinDistance:[51.526256,0.0,100.0]') return n; 开始n=节点:土工临时('Withindance:[51.526256,0.0100.0])返回n; 但这给了我这个错误(我现在在谷歌上搜索)

org.apache.lucene.queryParser.ParseException:无法解析“WithindInstance:[51.526256,0.0100.0]”:在第1行第35列遇到“]”“]”。 我期待的是: “到”。。。 ... ... 更新
在确定我的索引不存在并且它应该存在之后,我使用REST接口创建了一个名为SDN的索引,我希望SDN这样创建:

:POST /db/data/index/node { "name" : "location", "config" : { "provider" : "spatial", "geometry_type" : "point", "wkt" : "wkt" } } :POST/db/data/index/node { “名称”:“位置”, “配置”:{ “提供者”:“空间”, “几何图形类型”:“点”, “wkt”:“wkt” } } 而且,现在一切似乎都很好。所以,我的问题是,我应该手动创建索引吗?如果我查看org.springframework.data.neo4j.support.index.IndexType中的代码,它看起来应该完全使用我在上面使用的设置,但它只创建了名为Lucene的长索引:

public enum IndexType { @Deprecated SIMPLE { public Map getConfig() { return LuceneIndexImplementation.EXACT_CONFIG; } }, LABEL { public Map getConfig() { return null; } public boolean isLabelBased() { return true; }}, FULLTEXT { public Map getConfig() { return LuceneIndexImplementation.FULLTEXT_CONFIG; } }, POINT { public Map getConfig() { return MapUtil.stringMap( IndexManager.PROVIDER, "spatial", "geometry_type" , "point","wkt","wkt") ; } } ; public abstract MapgetConfig(); public boolean isLabelBased() { return false; } } 公共枚举索引类型 { @不赞成 简单{public Map getConfig(){return LuceneIndexImplementation.EXACT_CONFIG;}}, 标签{public Map getConfig(){return null;}public boolean islabelbase(){return true;}}, 全文{public Map getConfig(){return LuceneIndexImplementation.FULLTEXT_CONFIG;}}, 点{public Map getConfig(){return MapUtil.stringMap( IndexManager.PROVIDER,“空间”、“几何体类型”、“点”、“wkt”、“wkt”);} ; 公共抽象MapgetConfig(); 公共布尔值isLabelBased(){return false;} } 我确实清理了系统,行为也一样,我有没有错过一步

软件详细信息:

Java:
neo4j 2.0.1
neo4j ha 2.0.1
neo4j空间0.12-neo4j-2.0.1
spring-data-neo4j 3.0.0.0版本

独立服务器:
neo4j-enterprise-2.0.1

neo4j-spatial-0.12-neo4j-2.0.1-server-plugin

设置索引时,我不确定这是否是Spring数据中的错误,但使用REST索引手动创建索引有效:

:POST /db/data/index/node { "name" : "location", "config" : { "provider" : "spatial", "geometry_type" : "point", "wkt" : "wkt" } } :POST/db/data/index/node { “名称”:“位置”, “配置”:{ “提供者”:“空间”, “几何图形类型”:“点”, “wkt”:“wkt” } } 现在,我可以在@Query注释中使用cypher以最小的工作量执行查询(显然还有更多参数):

@查询(value=“start n=node:location('WithindInstance:[51.526256,0.0100.0]”)匹配用户-[wa:WAS_HERE]-n其中wa.ts>{ts}返回用户 页面findByTimeAtLocation(@Param(“ts”)长ts); start n=node:GeoTemporalThing('withinDistance:[51.526256,0.0,100.0]') return n; org.apache.lucene.queryParser.ParseException: Cannot parse 'withinDistance:[51.526256,0.0,100.0]': Encountered " "]" "] "" at line 1, column 35. Was expecting one of: "TO" ... ... ... :POST /db/data/index/node { "name" : "location", "config" : { "provider" : "spatial", "geometry_type" : "point", "wkt" : "wkt" } } public enum IndexType { @Deprecated SIMPLE { public Map getConfig() { return LuceneIndexImplementation.EXACT_CONFIG; } }, LABEL { public Map getConfig() { return null; } public boolean isLabelBased() { return true; }}, FULLTEXT { public Map getConfig() { return LuceneIndexImplementation.FULLTEXT_CONFIG; } }, POINT { public Map getConfig() { return MapUtil.stringMap( IndexManager.PROVIDER, "spatial", "geometry_type" , "point","wkt","wkt") ; } } ; public abstract MapgetConfig(); public boolean isLabelBased() { return false; } } :POST /db/data/index/node { "name" : "location", "config" : { "provider" : "spatial", "geometry_type" : "point", "wkt" : "wkt" } } @Query(value = "start n=node:location('withinDistance:[51.526256,0.0,100.0]') MATCH user-[wa:WAS_HERE]-n WHERE wa.ts > {ts} return user" Page findByTimeAtLocation(@Param("ts") long ts);