# ENRICH

The ENRICH command allows you to add data from existing indices as new columns using an enrich policy. This is useful for augmenting your data with additional information from other sources. Before using ENRICH, you must create and execute an enrich policy.

## Syntax

`ENRICH policy [ON match_field] [WITH [new_name1 = ]field1, [new_name2 = ]field2, ...]`

### Parameters

#### policy

The name of the enrich policy. You need to create and execute the enrich policy first.

#### mode

(Optional) The mode of the enrich command in cross cluster usage.

#### match_field

(Optional) The column used to match records in the enrich index. If not specified, the match is performed on the column with the same name as the match_field defined in the enrich policy.

#### fieldX

(Optional) The enrich fields from the enrich index to add as new columns. If a column with the same name as the enrich field already exists, it will be replaced. If not specified, all enrich fields defined in the policy are added.

#### new_nameX

(Optional) Allows you to rename the column added for each enrich field. Defaults to the enrich field name. If a column has the same name as the new name, it will be discarded. If a name (new or original) occurs more than once, only the rightmost duplicate creates a new column.

## Examples

Enriches a row by adding all fields defined in the `languages_policy` policy, matching on the `language_code` column.
```esql
ROW language_code = "1"
| ENRICH languages_policy
```

Enriches a row by matching on the `a` column instead of the default match field defined in the policy.
```esql
ROW a = "1"
| ENRICH languages_policy ON a
```

Enriches a row by matching on the `a` column and adding only the `language_name` field from the enrich index.
```esql
ROW a = "1"
| ENRICH languages_policy ON a WITH language_name
```

Enriches a row by matching on the `a` column and adding the `language_name` field as a column named `name`.
```esql
ROW a = "1"
| ENRICH languages_policy ON a WITH name = language_name
```

## Limitations

Before you can use ENRICH, you must create and execute an enrich policy. If a column name collides with an enrich field or new name, the existing column will be replaced or discarded. If a name occurs more than once, only the rightmost duplicate creates a new column.