parsemap

Extracts key-value pairs from a map-type field as individual fields.

Command properties

ItemDescription
Command typeProcessing query
Required permissionNone
License usageN/A
Parallel executionSupported
Distributed executionNot 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 codeMessageDescription
22100Enter 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

  1. Extracting key-value pairs from a map field

    json "{'complex': {'id': 100, 'name': 'Logpresso'}}" | parsemap field=complex
    

    Extracts the id and name fields from the map in the complex field.

  2. Extracting while preserving the original fields

    json "{'line': '<doc><name locale=\"ko\">Logpresso</name></doc>'}"
    | parsexml
    | parsemap field=name overlay=t
    

    When the name field extracted by the parsexml command is a map type, use overlay=t to preserve the original fields while extracting the map's key-value pairs as fields.