[英]How can I get the value of the result in NEO4J Cypher Query in JAVA
i'm newbie in neo4j 我是neo4j的新手
actually, I write some query to find the distinct cluster number of graph in java 实际上,我编写了一些查询来查找java中图的不同簇数
like this 像这样
result = engine.execute("START n=node:nodes(\"id:"+queryId+"\") "+
"MATCH (n)-[s]-(ns) "+ "WITH collect(distinct ns.cluster) as nc1 "+"RETURN nc1 ");
and then I printed the value of nc1 like this 然后我像这样打印nc1的值
for( Map<String, Object> row : result ) {
for ( Entry<String, Object> column : row.entrySet() ){
String key = column.getKey();
Object value = column.getValue();
if(key.equals("nc1")){
System.out.println(value)
}
}
it was successful I can see the list for example, [ 12, 34, 55, 60 ]. 成功,我可以看到例如[12、34、55、60]的列表。
but I cannot extract the number of the list 但我无法提取列表编号
how can I extract the exact value in object value.. I have no idea. 如何提取对象值中的确切值。我不知道。
please help me 请帮我
thank you 谢谢
Try changing your codes to:: 尝试将代码更改为::
for( Map<String, Object> row : result ) {
for ( Entry<String, Object> column : row.entrySet() ){
String key = column.getKey();
Object value = column.getValue();
if(key.equals("nc1")){
System.out.println(value);
int[] array=new int[(int) value];
System.out.println(array[0]);
System.out.println(array[1]);
System.out.println(array[2]);//Upto the no. of value of nc1
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.