2014-02-07 92 views
0

我是新手在Neo4j的我怎樣才能獲得結果的Neo4j的Cypher查詢的價值在JAVA

其實,我寫一些查詢來查找圖形的不同簇號在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]。

,但我不能提取列表

我怎麼能提取物價值..精確值,我不知道數量。

請幫我

謝謝

+1

要打印與每個鍵關聯的密鑰或價值觀@kujungmul –

+0

嗯,我可以打印nc1的值,但我不知道如何提取nc1中的每個元素。 – kujungmul

+0

你可以嘗試一下代碼並檢查它是否給出了期望的輸出 –

回答

3

試着改變你的代碼::

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

非常感謝你:-) – kujungmul

+0

@kujungmul歡迎來到stackoverflow,如果答案幫助你解決你的問題,比試着投票或接受答案,它會幫助別人。 –