Display all node and their property when properties are List

Hi everyone !

My question :

I would like to display all my nodes and their properties.
All properties are list which contains Strings.

I tried < MATCH (n) RETURN properties(n)>

It worked but the contains of the list display is an address. Something like that ":Ljava.lang.String;@6b6606d1"

I also try with UNWIND but it did not work.
(I use cypher command with JAVA)

Thanks

What tool do you see that from?
How did your property data get populated?

Hello Benjamin, and welcome to the Neo4j community!

There are many ways to restructure data like yours, but the big question is, "what are you restructuring it to?"

Considering you want to display all properties of all nodes, your results can go a variety of directions, especially considering that your properties are lists.

MATCH (n) RETURN (n) 

...will display all of your nodes and their properties, if you clikc on the table resutls (left side of results panel).

If you want something a little more in the right direction:

MATCH (n)
UNWIND keys(n) as property
RETURN id(n), n.id, n.name, property, n[property]
1 Like

Thanks for all your answer.

Currently I am using a community server.

I use "DatabaseManagementService" & "GraphDatabaseService" under java. That's to say I am printing data on my eclipse console : i find this function on Neo4J to display :

	try(Transaction tx = graphDb.beginTx()){
		String rows = "";	
		
	Result result=tx.execute("HERE I SHOULD WRITE MY CYPHER COMMAND");
	
		while( result.hasNext()) {
			Map<String,Object> row = result.next();
			for(Entry<String, Object> column : row.entrySet()) {
				rows += column.getKey() + ": " + column.getValue() + "; ";
			}
			rows += "\n";
		}			
		System.out.println(rows);		
	}

The problem is that the content of my list of string is not display as i want, i try many cypher command that work with a SandBox but not with function under Java. (The problem probably come from the function...)

About populated data, I parse them with java from several XML files, then I store data in a Java class.
But data store are fine i think because if i check the content of the property one by one, the content is good, but i do not want to type a cypher command for displaying all my labels & nodes.

If you have any additional questions do not hesitate to ask me!

Try running the command I sent above, in the browser. You'll see that your data is likely a bit more complex than you're thinking. You'll have to make decisions about how the result should appear, and where/how to simplify/flatten your tree into a list.

You could also pass that command into your code above, with some minor adjustments.

class MyClass {
   
   ...
   
   public void doThis() {
        try (Transaction tx = graphDb.beginTx()) {
            String rows = "";

            Result result = tx.execute("HERE I SHOULD WRITE MY CYPHER COMMAND");

            while (result.hasNext()) {
                rows += this.buildRowString(result.next());
            }

            System.out.println(rows);
        }
    }

    private String buildRowString(Map<String,Object> row) {
        String result = "";
        for(Map.Entry<String, Object> column : row.entrySet()) {
            String key = column.getKey();
            String value = "";
            try {
                value = (String) column.getValue();
            } catch (Exception e) {
                value = e.getMessage();
            }

            result += key + ": " + value + "; ";
        }

        return result + "\n";
    }
1 Like