apoc.map.fromNodes

Details

Syntax

apoc.map.fromNodes(label, prop)

Description

Returns a MAP of the given prop to the node of the given label.

Arguments

Name

Type

Description

label

STRING

The node labels from which the map will be created.

prop

STRING

The property name to map the returned nodes by.

Returns

MAP

Usage Examples

The examples in this section are based on the following sample graph:

CREATE (TheMatrixRevolutions:Movie {title:'The Matrix Revolutions', released:2003, tagline:'Everything that has a beginning has an end'})
CREATE (YouveGotMail:Movie {title:"You've Got Mail", released:1998, tagline:'At odds in life... in love on-line.'})
CREATE (SleeplessInSeattle:Movie {title:'Sleepless in Seattle', released:1993, tagline:'What if someone you never met, someone you never saw, someone you never knew was the only someone for you?'});
RETURN apoc.map.fromNodes("Movie", "title");
Results
Output
{
  "The Matrix Revolutions": {
    "identity": 14,
    "labels": [
      "Movie"
    ],
    "properties": {
    "tagline": "Everything that has a beginning has an end",
    "title": "The Matrix Revolutions",
    "released": 2003
    }
  },
  "Sleepless in Seattle": {
    "identity": 16,
    "labels": [
      "Movie"
    ],
    "properties": {
    "tagline": "What if someone you never met, someone you never saw, someone you never knew was the only someone for you?",
    "title": "Sleepless in Seattle",
    "released": 1993
    }
  },
  "You've Got Mail": {
    "identity": 15,
    "labels": [
      "Movie"
    ],
    "properties": {
    "tagline": "At odds in life... in love on-line.",
    "title": "You've Got Mail",
    "released": 1998
    }
  }
}