Graph Neo4j和Lucene多键查询(或者:我应该使用Cypher吗?)
我在Neo4j中有一个图,其中节点表示平面中的随机点,每个节点的坐标存储为属性x和y,值类型为double。 我创建节点并为其编制索引:Graph Neo4j和Lucene多键查询(或者:我应该使用Cypher吗?),graph,lucene,neo4j,cypher,Graph,Lucene,Neo4j,Cypher,我在Neo4j中有一个图,其中节点表示平面中的随机点,每个节点的坐标存储为属性x和y,值类型为double。 我创建节点并为其编制索引: IndexManager index = graph.index(); Index<Node> nodesIndex = index.forNodes("points"); for (int i = 0; i < points.length; i++) { Point p = points[i];
IndexManager index = graph.index();
Index<Node> nodesIndex = index.forNodes("points");
for (int i = 0; i < points.length; i++) {
Point p = points[i];
Node n;
Transaction tx = graph.beginTx();
try {
n = graph.createNode();
n.setProperty("x", p.getX());
n.setProperty("y", p.getY());
nodesIndex.add(n, "x", new ValueContext(p.getX()).indexNumeric());
nodesIndex.add(n, "y", new ValueContext(p.getY()).indexNumeric());
tx.success();
} finally {
tx.finish();
}
}
以下是回应:
Node
Properties
y 1.0
x 14.0
Node info
self /db/data/node/10
Node
Properties
y 1.0
x 2.0
Node info
self /db/data/node/7
Node
Properties
y 1.0
x 6.0
Node info
self /db/data/node/8
Node
Properties
y 1.0
x 7.0
Node info
self /db/data/node/9
[Etc...]
如你所见,它不起作用。我不明白为什么我需要配置索引?。
注意,我没有必要使用Lucene。如果有一种方法可以用Cypher从以正方形区域为中心的节点开始收集信息,实际上会更好,因为我还需要找到的节点之间的关系
附加信息
如果这很重要,该图表示平面上随机点集上的Delaunay三角剖分。更抽象地说,我需要提取位于给定区域的整个子图
非常感谢您的帮助 恐怕您不能通过Cypher执行此操作。Cypher无法推断您希望为该查询使用数值上下文,可能在未来版本中的某些索引元信息中,您需要这样才能以您希望的方式查询Lucene。相对于REST,最简单的方法可能是使用Groovy,请参阅
Node
Properties
y 1.0
x 14.0
Node info
self /db/data/node/10
Node
Properties
y 1.0
x 2.0
Node info
self /db/data/node/7
Node
Properties
y 1.0
x 6.0
Node info
self /db/data/node/8
Node
Properties
y 1.0
x 7.0
Node info
self /db/data/node/9
[Etc...]