%% Search Nodes by Property Key and Value
% 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);

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

neo4jconn.Message

%
% Search the database for nodes that have node label Person using the Neo4j database connection neo4jconn. Filter the results further by the property key and value for a specific person named User2. The nodeinfo output argument is a Neo4jNode object that contains node information.

nlabel = 'Person';

nodeinfo = searchNode(neo4jconn,nlabel,'PropertyKey','name', ...
    'PropertyValue','User2')

%
% Access the node information. The structure contains a property key and value for User2.

nodeinfo.NodeData

%
% Find the node degree of the outgoing relationships. There is one outgoing relationship type knows for User2.

degree = nodeDegree(nodeinfo,'out')

%
% Close the database connection.

close(neo4jconn)

% Copyright 2018 The MathWorks, Inc.