Question

i'm newbie in neo4j

actually, I write some query to find the distinct cluster number of graph in 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

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 ].

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

Était-ce utile?

La solution

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
}
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top