Fingerprint
Synopsis
Generates a cryptographic hash of specified document fields to create a unique fingerprint.
Schema
fingerprint:
- fields: <ident[]>
- method: <string>
- target_field: <ident>
- salt: <string>
- description: <text>
- if: <script>
- ignore_failure: <boolean>
- ignore_missing: <boolean>
- on_failure: <processor[]>
- on_success: <processor[]>
- tag: <string>
Configuration
Field | Required | Default | Description |
---|---|---|---|
fields | Y | - | Array of field names to include in the fingerprint |
method | N | SHA-1 | Hash algorithm: MD5 , SHA-1 , SHA-256 , or SHA-512 |
target_field | N | fingerprint | Field to store the generated hash |
salt | N | - | Additional value to include in the hash calculation |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | If true , errors are ignored |
ignore_missing | N | false | If true , missing fields are skipped |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
Details
The processor supports multiple hash algorithms and can handle complex data types including nested objects and arrays. It ensures consistent hashing by sorting the object keys before hashing, using delimiters between values and converting various data types to bytes uniformly:
Strings | Direct byte conversion |
Numbers | Binary representation |
Booleans | 1 for true , 2 for false |
Arrays | All elements in order |
Objects | Keys sorted alphabetically |
Dates | Uses the RFC3339Nano format |
Null | Empty bytes |
For consistent hashing, use the same method
and salt
across comparisons. Consider field presence/absence with ignore_missing
, and keep in mind that object key order is normalized.
Object keys are included in the hash calculation for nested objects, and field order in the fields
array doesn't affect the hash. Missing fields with ignore_missing
set to false
cause processor failure.
Common use cases:
-
Document Deduplication
fingerprint:
- fields: ["content", "metadata"]
- method: SHA-256
- target_field: content_hash -
Change Detection
fingerprint:
- fields: ["user.profile", "user.settings"]
- method: SHA-1
- target_field: profile_hash -
Data Integrity
fingerprint:
- fields: ["payload"]
- method: SHA-512
- salt: "verification-key"
Examples
Basic
Hashing simple field values... |
|
creates base64 encoding: |
|
Nested Objects
Hashing nested object fields... |
|
includes all the nested values: |
|
Salt
Adding salt to the hash calculation... |
|
creates a salted hash: |
|
Missing Fields
Skipping missing fields... |
|
creates the hash from the available fields: |
|