user6517480
user6517480

Reputation:

Neo4j - Spring get String list from labels

How can i retrieve in Spring a List from this query

MATCH (n) WITH DISTINCT LABELS (n) as labels RETURN labels

Which doesn't create a node, but return just some strings referred to all different labels in my neo4j database?

Upvotes: 2

Views: 710

Answers (1)

Luanne
Luanne

Reputation: 19373

If you use the org.neo4j.ogm.session.Session.query method that returns a org.neo4j.ogm.model.Result, you should have a column called labels that contains the labels returned by your query.

You can also use @Query in your repository like this:

  @Query("MATCH (n) WITH DISTINCT LABELS (n) as labels RETURN labels")
  List<String> findLabels();

Upvotes: 5

Related Questions