【问题标题】:How can I get the value of the result in NEO4J Cypher Query in JAVA如何在 JAVA 中获取 NEO4J Cypher Query 中的结果值
【发布时间】:2014-02-07 05:29:18
【问题描述】:

我是 neo4j 的新手

实际上,我编写了一些查询来查找 java 中图形的不同簇数

喜欢这个

result = engine.execute("START n=node:nodes(\"id:"+queryId+"\") "+
"MATCH (n)-[s]-(ns) "+  "WITH collect(distinct ns.cluster) as nc1 "+"RETURN nc1 ");

然后我像这样打印了 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)
    }
}

成功了 我可以看到列表 例如 [ 12, 34, 55, 60 ]。

但我无法提取列表的编号

如何提取对象值中的确切值。我不知道。

请帮帮我

谢谢

【问题讨论】:

  • 您想打印键或与每个键关联的值?? @kujungmul
  • 嗯,我可以打印nc1的值,但是我不知道如何提取nc1中的每个元素。
  • 您可以尝试代码并检查它是否提供所需的输出

标签: java neo4j cypher graph-databases


【解决方案1】:

尝试将您的代码更改为::

   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
}
}

【讨论】:

  • @kujungmul 欢迎来到stackoverflow,如果答案帮助您解决了问题,请尝试投票或接受答案,这将对其他人有所帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多