|| apoc.hashing.fingerprinting - APOC 核心文档 - Neo4j 文档

apoc.hashing.fingerprinting

详情

语法

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

描述

计算 `NODE` 或 `RELATIONSHIP` 的 MD5 校验和(相同实体共享相同的校验和)。与 `apoc.hashing.fingerprint()` 不同,此函数支持许多配置参数。不适用于加密用例。

参数

名称

类型

描述

object

ANY

要哈希的节点或关系。

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> } 默认值为:`{}`。

返回

STRING

配置参数

`apoc.hashing.fingerprinting` 配置参数
名称 类型 默认值 描述

digestAlgorithm

STRING

"MD5"

用于计算指纹的算法。支持的值包括:`MD5`、`SHA-1`、`SHA-256`

strategy

STRING

"LAZY"

定义节点/关系的过滤行为。支持的值包括:

  • `LAZY` - 不包括属性。

  • `EAGER` - 包括所有未过滤的属性。

nodeAllowMap

MAP<STRING, LIST<STRING>>

{}

节点标签名称映射到该标签允许的属性列表。

nodeDisallowMap

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>

[]

全局忽略的关系属性列表。

使用示例

本节示例基于以下示例图

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

以下为 Ryan 生成指纹

MATCH (person:Person {name: "Ryan"})
RETURN apoc.hashing.fingerprinting(person) AS output;
结果
输出

"D41D8CD98F00B204E9800998ECF8427E"

以下使用 `EAGER` 策略为 Ryan 生成指纹,该策略包括节点属性

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

"81C99DD6C9382C4E01A1873F9E818CE0"

以下为 Ryan 生成指纹,排除 `name` 属性

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

"D41D8CD98F00B204E9800998ECF8427E"

以下使用 `SHA-256` 算法为 Ryan 生成指纹

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

"E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855"

如果想对指纹生成有较少控制,请参阅 apoc.hashing.fingerprint

© . This site is unofficial and not affiliated with Neo4j, Inc.