parsemap
Extracts key-value pairs from a map-type field as individual fields.
Command properties
| Item | Description |
|---|---|
| Command type | Processing query |
| Required permission | None |
| License usage | N/A |
| Parallel execution | Supported |
| Distributed execution | Not supported |
Syntax
parsemap field=FIELD [overlay={t|f}]
Options
field=FIELD- Name of the field containing the map-type value. This option is required.
overlay={t|f}- When set to
t, preserves the original record's fields and overlays the map's key-value pairs onto them. When omitted, outputs only the map's key-value pairs. (default:f)
Error codes
Parse errors
| Error code | Message | Description |
|---|---|---|
| 22100 | Enter the field. | The field option is not specified |
Description
The parsemap command extracts key-value pairs from the map value in the specified field and creates each key as a field. If the specified field is not a map type or is null, the original record is passed through unchanged.
Examples
-
Extracting key-value pairs from a map field
json "{'complex': {'id': 100, 'name': 'Logpresso'}}" | parsemap field=complexExtracts the
idandnamefields from the map in thecomplexfield. -
Extracting while preserving the original fields
json "{'line': '<doc><name locale=\"ko\">Logpresso</name></doc>'}" | parsexml | parsemap field=name overlay=tWhen the
namefield extracted by the parsexml command is a map type, useoverlay=tto preserve the original fields while extracting the map's key-value pairs as fields.