NAME
Neo4j::Bolt - query Neo4j using Bolt protocol
SYNOPSIS
use
Neo4j::Bolt;
$stream
=
$cxn
->run_query(
"MATCH (a) RETURN head(labels(a)) as lbl, count(a) as ct"
,
{}
# parameter hash required
);
@names
=
$stream
->field_names;
while
(
my
@row
=
$stream
->fetch_next ) {
"For label '$row[0]' there are $row[1] nodes.\n"
;
}
$stream
=
$cxn
->run_query(
"MATCH (a) RETURN labels(a) as lbls, count(a) as ct"
,
{}
# parameter hash required
);
while
(
my
@row
=
$stream
->fetch_next ) {
"For label set ["
.
join
(
','
,@{
$row
[0]}).
"] there are $row[1] nodes.\n"
;
}
DESCRIPTION
Neo4j::Bolt is a Perl wrapper around Chris Leishmann's excellent libneo4j-client library implementing the Neo4j Bolt network protocol. It uses Ingy's Inline::C to do all the hard XS work.
Return Types
Neo4j::Bolt::ResultStream returns rows resulting from queries made via a Neo4j::Bolt::Cxn. These rows are simple arrays of scalars and/or references. These represent Neo4j types according to the following:
Neo4j type Perl representation
----- ---- ---- --------------
Null
undef
Bool Perl core bool (v5.36+) or JSON::PP::Boolean
Int
scalar
Float
scalar
String
scalar
Bytes scalarref (Neo4j::Bolt::Bytes)
DateTime hashref (Neo4j::Bolt::DateTime)
Duration hashref (Neo4j::Bolt::Duration)
Point hashref (Neo4j::Bolt::Point)
List arrayref
Map hashref
Node hashref (Neo4j::Bolt::Node)
Relationship hashref (Neo4j::Bolt::Relationship)
Path arrayref (Neo4j::Bolt::Path)
Nodes, Relationships and Paths are represented in the following formats:
# Node:
bless
{
id
=>
$node_id
,
labels
=> [
$label1
,
$label2
, ...],
properties
=> {
prop1
=>
$value1
,
prop2
=>
$value2
, ...}
},
'Neo4j::Bolt::Node'
# Relationship:
bless
{
id
=>
$reln_id
,
type
=>
$reln_type
,
start
=>
$start_node_id
,
end
=>
$end_node_id
,
properties
=> {
prop1
=>
$value1
,
prop2
=>
$value2
, ...}
},
'Neo4j::Bolt::Relationship'
# Path:
bless
[
$node1
,
$reln12
,
$node2
,
$reln23
,
$node3
, ...
],
'Neo4j::Bolt::Path'
For further details, see the individual modules:
METHODS
- connect($url), connect_tls($url,$tls_hash)
-
Class method, connect to Neo4j server. The URL scheme must be
'bolt'
, as inReturns object of type Neo4j::Bolt::Cxn, which accepts Cypher queries and returns a Neo4j::Bolt::ResultStream.
To connect by SSL/TLS, use connect_tls, with a hashref with keys as follows
ca_dir
=> <path/to/dir/of/CAs
ca_file
=> <path/to/file/of/CAs
pk_file
=> <path/to/private/key.pm
pk_pass
=> <private/key.pm passphrase>
Example:
$cxn
= Neo4j::Bolt->connect_tls(
'bolt://all-the-young-dudes.us:7687'
, {
ca_cert
=>
'/etc/ssl/cert.pem'
});
When neither
ca_dir
norca_file
are specified, an attempt will be made to use the default trust store instead. This requires IO::Socket::SSL or Mozilla::CA to be installed. - set_log_level($LEVEL)
-
When $LEVEL is set to one of the strings
ERROR WARN INFO DEBUG
orTRACE
, libneo4j-client native logger will emit log messages at or above the given level, on STDERR.Set to
NONE
to turn off completely (the default).
SEE ALSO
Neo4j::Bolt::Cxn, Neo4j::Bolt::ResultStream, Neo4j::Types.
AUTHOR
Mark A. Jensen
CPAN: MAJENSEN
majensen -at- cpan -dot- org
CONTRIBUTORS
Arne Johannessen (AJNN)
LICENSE
This software is Copyright (c) 2019-2024 by Mark A. Jensen.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004