编写密码并获取 Java 中所有属性的正确方法
Proper way to write cypher and get all properties in Java
我正在使用以下代码从节点获取信息:
public void allResturants (){
final QueryResult<Map<String,Object>> result = engine.query("MATCH (n:`Restaurant`) RETURN n.name as name, n.website as web, n.address as address LIMIT 25", null);
for (Map<String, Object> row : result) {
String name=((String)row.get("name"));
System.out.println("name is " + name);
}
}
有没有一种方法可以 select 通过查询直接节点(如:MATCH(n:Restaurant) RETURN n
)
然后迭代并获取其属性。
这个查询实际上看起来很长,属性数量更多:
MATCH (n:`Restaurant`) RETURN n.name as name, n.website as web, n.address as address LIMIT 25;
我想要 select * from tableName;
.
Return整个节点:
MATCH (n:`Restaurant`) RETURN n LIMIT 25;
然后在 java 代码中:
public void allResturants (){
final QueryResult<Map<String,Object>> result = engine.query("...", null);
for (Map<String, Object> row : result) {
Node node = (Node) map.get("n"); // org.neo4j.graphdb.Node
System.out.println("name is " + node.getProperty("name"));
}
}
适用于嵌入式和 REST 数据库。
我正在使用以下代码从节点获取信息:
public void allResturants (){
final QueryResult<Map<String,Object>> result = engine.query("MATCH (n:`Restaurant`) RETURN n.name as name, n.website as web, n.address as address LIMIT 25", null);
for (Map<String, Object> row : result) {
String name=((String)row.get("name"));
System.out.println("name is " + name);
}
}
有没有一种方法可以 select 通过查询直接节点(如:MATCH(n:Restaurant) RETURN n
)
然后迭代并获取其属性。
这个查询实际上看起来很长,属性数量更多:
MATCH (n:`Restaurant`) RETURN n.name as name, n.website as web, n.address as address LIMIT 25;
我想要 select * from tableName;
.
Return整个节点:
MATCH (n:`Restaurant`) RETURN n LIMIT 25;
然后在 java 代码中:
public void allResturants (){
final QueryResult<Map<String,Object>> result = engine.query("...", null);
for (Map<String, Object> row : result) {
Node node = (Node) map.get("n"); // org.neo4j.graphdb.Node
System.out.println("name is " + node.getProperty("name"));
}
}
适用于嵌入式和 REST 数据库。