VivekDev
VivekDev

Reputation: 25553

Cyper query for showing the labels on Neo4j

I have created 4 user nodes(user is the label here) and 3 contact nodes using the following commands.

CREATE (:User {clientType: "individual",    firstName:  "User1", emailID: "[email protected]"});
CREATE (:User {clientType: "institute",     firstName:  "User2", emailID: "[email protected]"});
CREATE (:User {clientType: "college",       firstName:  "User3", emailID: "[email protected]"});
CREATE (:User {clientType: "corporate",     firstName:  "User4", emailID: "[email protected]"});

CREATE (:Contact {address1: "4, Kashmira Apartments" });
CREATE (:Contact {address1: "503, Neelkanth Corporate Park"});
CREATE (:Contact {address1: "VJTI Institute"});

Now when I use CALL apoc.meta.graph() or CALL db.schema(), I get the following diagram showing only the labels. Calling db.Schema

But when I use match syntax(MATCH (n) RETURN n) of CQL we get the diagram showing all of the nodes.

Using Match Syntax of the CQL

Now my question is how can I show only the labels using CQL? Just show only the labels with anything like

MATCH (n) RETURN UNIQE lables //This does not work 

Upvotes: 0

Views: 124

Answers (2)

cybersam
cybersam

Reputation: 67044

Cypher (not CQL, which is another language) is the neo4j query language. The neo4j Browser is a tool that allows you to enter Cypher queries and visualize the results.

If you are asking how to make the neo4j Browser caption a node with its label(s), you can't. However, since the Browser allows you to assign different colors to different labels, this is usually not a problem.

Upvotes: 0

To get node labels use functions labels(); this function return list with all node labels

match (n) return labels(n) limit 1;

If your goal to get list with all labels in graph then use

call db.labels;

Hope it helps!

Upvotes: 2

Related Questions