This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Neo4jConnect

Neo4j database connection

Description

Create a Neo4j® database connection using the MATLAB® interface to Neo4j with the REST API. With the Neo4j database connection, you can explore the graph database, update the graph database, store a MATLAB directed graph, and perform graph analytics using the MATLAB directed graph.

You can also create a Neo4j database connection using the Database Toolbox™ Interface for Neo4j Bolt Protocol. To use this interface, you must install the Database Toolbox Interface for Neo4j Bolt Protocol. For details, see Database Toolbox Interface for Neo4j Bolt Protocol Installation.

With a Neo4jConnect object, you can perform these tasks:

  • Explore the graph database for nodes and relationships.

  • Search the graph database for nodes, relationships, or a subgraph.

  • Store a directed graph.

  • Update nodes and relationships in the graph database.

  • Execute a Cypher® query.

Creation

Create a Neo4jConnect object using neo4j.

Properties

expand all

This property is read-only.

Neo4j database connection URL that contains the server, port number, and web location of the Neo4j database, specified as a character vector.

If you specify a Bolt database connection URL using the Database Toolbox Interface for Neo4j Bolt Protocol, then the neo4j function creates a Bolt connection instead.

Example: http://localhost:7474/db/data specifies using the HTTP protocol where localhost is the server, 7474 is the port number, and /db/data is the web location of the database.

Example: bolt://localhost:7687/db/data specifies using the Bolt protocol where localhost is the server, 7687 is the port number, and /db/data is the web location of the database.

Data Types: char

This property is read-only.

User name for accessing the Neo4j database, specified as a character vector.

Data Types: char

This property is read-only.

Error message, specified as a character vector. If this property is empty, the database connection is successful.

Data Types: char

Object Functions

expand all

closeClose Neo4j database connection
nodeLabelsAll node labels in Neo4j database
relationTypesAll relationship types in Neo4j database
propertyKeysAll property keys in Neo4j database
searchNodeByIDSearch Neo4j database nodes by node identifier
searchNodeSearch Neo4j database nodes by label or by property key and value
searchRelationSearch relationships for Neo4j database node
searchRelationByIDSearch Neo4j relationship by relationship identifier
searchGraphSearch for subgraph or entire graph in Neo4j database
createNodeCreate nodes in Neo4j database
createRelationCreate relationships between nodes in Neo4j database
deleteNodeDelete nodes from Neo4j database
deleteRelationDelete relationships from Neo4j database
addNodeLabelAdd labels to nodes in Neo4j database
removeNodeLabelRemove labels from nodes in Neo4j database
removeNodePropertyRemove properties from nodes in Neo4j database
removeRelationPropertyRemove properties from relationships in Neo4j database
setNodePropertySet properties for nodes in Neo4j database
setRelationPropertySet properties for relationships in Neo4j database
updateNodeUpdate node labels and properties in Neo4j database
updateRelationUpdate relationship properties in Neo4j database
storeDigraphStore directed graph in Neo4j database
executeCypherExecute Cypher query on Neo4j database

Examples

collapse all

Create a Neo4j® database connection using the URL http://localhost:7474/db/data, user name neo4j, and password matlab.

url = 'http://localhost:7474/db/data';
username = 'neo4j';
password = 'matlab';

neo4jconn = neo4j(url,username,password)
neo4jconn = 
  Neo4jConnect with properties:

         URL: 'http://localhost:7474/db/data/'
    UserName: 'neo4j'
     Message: []

neo4j returns a Neo4jConnect object with these properties:

  • URL — The Neo4j database web location

  • UserName — The user name used to connect to the database

  • Message — Any database connection error messages

Check the Message property of the Neo4j connection object neo4jconn. The blank Message property indicates a successful Neo4j database connection.

neo4jconn.Message
ans =

     []

Retrieve all node labels using the Neo4j database connection neo4jconn. The cell array nlabels contains a character vector for the one node label in the Neo4j database.

nlabels = nodeLabels(neo4jconn)
nlabels = 1×1 cell array
    {'Person'}

Close the database connection.

close(neo4jconn)

Introduced in R2016b