apoc.hashing.fingerprinting

Details

Syntax

apoc.hashing.fingerprinting(object [, config ])

Description

Calculates a MD5 checksum over a NODE or RELATIONSHIP (identical entities share the same checksum). Unlike apoc.hashing.fingerprint(), this function supports a number of config parameters. Unsuitable for cryptographic use-cases.

Arguments

Name

Type

Description

object

ANY

A node or relationship to hash.

config

MAP

{ digestAlgorithm = "MD5" :: STRING, strategy = "LAZY" :: STRING, nodeAllowMap = [] :: MAP<STRING, LIST<STRING>>, relAllowMap = [] :: MAP<STRING, LIST<STRING>>, relDisallowMap = [] :: MAP<STRING, LIST<STRING>>, mapAllowList = [] :: LIST<STRING>, mapDisallowList = [] :: LIST<STRING>, allNodesAllowList = [] :: LIST<STRING>, allNodesDisallowList = [] :: LIST<STRING>, allRelsAllowList = [] :: LIST<STRING>, allRelsDisallowList = [] :: LIST<STRING> } The default is: {}.

Returns

STRING

Config parameters

apoc.hashing.fingerprinting configuration params
name type default description

digestAlgorithm

STRING

"MD5"

The algorithm used to compute the fingerprint. Supported values are: MD5, SHA-1, SHA-256

strategy

STRING

"LAZY"

Defines the filtering behaviour of nodes/relationships. Supported values are:

  • LAZY - does not include properties.

  • EAGER - includes all non-filtered properties.

nodeAllowMap

MAP<STRING, LIST<STRING>>

{}

Node label name mapped to a list of allowed properties for that label.

nodeDisallowMap

MAP<STRING, LIST<STRING>>

[]

Node label name mapped to a list of properties to ignore for that label.

relAllowMap

MAP<STRING, LIST<STRING>>

{}

Relationship type name mapped to a list of allowed properties for that type.

relDisallowMap

MAP<STRING, LIST<STRING>>

[]

Relationship type name mapped to a list of properties to ignore for that type.

mapAllowList

LIST<STRING>

[]

A list of allowed keys when the object being hashed is a map.

mapDisallowList

LIST<STRING>

[]

A list of keys to ignore when the object being hashed is a map.

allNodesAllowList

LIST<STRING>

[]

A list of globally allowed node properties

allNodesDisallowList

LIST<STRING>

[]

A list of globally ignored node properties.

allRelsAllowList

LIST<STRING>

[]

A list of globally allowed relationship properties.

allRelsDisallowList

LIST<STRING>

[]

A list of globally ignored relationship properties.

Usage Examples

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

MERGE (joe:Person {name: "Joe"})
MERGE (ryan:Person {name: "Ryan"})
MERGE (ryan)-[:FOLLOWS {since: datetime("2020-11-04")}]->(joe);

The following generates the fingerprint for Ryan:

MATCH (person:Person {name: "Ryan"})
RETURN apoc.hashing.fingerprinting(person) AS output;
Results
output

"D41D8CD98F00B204E9800998ECF8427E"

The following generates the fingerprint for Ryan, using the EAGER strategy, which includes node properties:

MATCH (person:Person {name: "Ryan"})
RETURN apoc.hashing.fingerprinting(person, {
  strategy: "EAGER"
}) AS output;
Results
output

"81C99DD6C9382C4E01A1873F9E818CE0"

The following generates the fingerprint for Ryan, excluding the name property:

MATCH (person:Person {name: "Ryan"})
RETURN apoc.hashing.fingerprinting(person, {
  allNodesDisallowList: ["name"]
}) AS output;
Results
output

"D41D8CD98F00B204E9800998ECF8427E"

The following generates the fingerprint for Ryan, using the SHA-256 algorithm:

MATCH (person:Person {name: "Ryan"})
RETURN apoc.hashing.fingerprinting(person, {
  digestAlgorithm: "SHA-256"
}) AS output;
Results
output

"E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855"

If we want less control over the generation of the fingerprint, see apoc.hashing.fingerprint.