Skip to content

Commit

Permalink
Add Migration Assistant Type Mapping documentation
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Kurait <[email protected]>
  • Loading branch information
AndreKurait committed Feb 7, 2025
1 parent 8fe5adc commit 929c53e
Showing 1 changed file with 189 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
---
layout: default
title: Handling type mapping deprecation
nav_order: 60
parent: Planning your migration
grand_parent: Migration phases
redirect_from:
- /migration-assistant/migration-phases/handling-type-mapping-deprecation/
---

# Handling type mapping deprecation

During a migration from Elasticsearch versions 6.x and before, you may have used the type mapping feature. This page provides a cookbook of different scenarios and templates that can be used to handle these deprecations.

## Understanding type mapping deprecation

Elasticsearch indices created prior to 6.x could contain multiple types per index. This feature has been deprecated and removed in newer versions of Elasticsearch and OpenSearch. Because of this, during migrations, you may need to specify the behavior to occur when migrating items that used type mappings. For more details, refer to [Elasticsearch's official documentation on the removal of mapping types](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/removal-of-types.html).

Check failure on line 17 in _migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [OpenSearch.SubstitutionsError] Use 'indexes' instead of 'indices'. Raw Output: {"message": "[OpenSearch.SubstitutionsError] Use 'indexes' instead of 'indices'.", "location": {"path": "_migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md", "range": {"start": {"line": 17, "column": 15}}}, "severity": "ERROR"}

## Handling type mapping deprecation

To handle type mapping deprecation, you can leverage the built in TypeMappingsSanitizationTransformer. This transformer can be used to transform the data (metadata, documents, requests) and update the behavior accordingly.

### Using the TypeMappingsSanitizationTransformer

1. Navigate to the bootstrap box and open the `cdk.context.json` with vim.
2. Add/Update the key `reindexFromSnapshotExtraArgs` to include `--doc-transformer-config-file /shared-logs-output/transformation.json`. [^1]

Check failure on line 26 in _migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [Vale.Terms] Use 'JSON' instead of 'json'. Raw Output: {"message": "[Vale.Terms] Use 'JSON' instead of 'json'.", "location": {"path": "_migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md", "range": {"start": {"line": 26, "column": 131}}}, "severity": "ERROR"}
3. Add/Update the key `trafficReplayerExtraArgs` to include `--transformer-config-file /shared-logs-output/transformation.json`. [^1]

Check failure on line 27 in _migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [Vale.Terms] Use 'JSON' instead of 'json'. Raw Output: {"message": "[Vale.Terms] Use 'JSON' instead of 'json'.", "location": {"path": "_migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md", "range": {"start": {"line": 27, "column": 123}}}, "severity": "ERROR"}
4. Deploy/redeploy the Migration Assistant.
5. Navigate to the Migration Assistant console.
6. Create a file with `vim /shared-logs-output/transformation.json`. [^1]

Check failure on line 30 in _migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [Vale.Terms] Use 'JSON' instead of 'json'. Raw Output: {"message": "[Vale.Terms] Use 'JSON' instead of 'json'.", "location": {"path": "_migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md", "range": {"start": {"line": 30, "column": 63}}}, "severity": "ERROR"}
7. Add your transformation configuration to the file (see examples below).

Check warning on line 31 in _migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [OpenSearch.DirectionAboveBelow] Use 'following or later' instead of 'below' for versions or orientation within a document. Use 'above' and 'below' only for physical space or screen descriptions. Raw Output: {"message": "[OpenSearch.DirectionAboveBelow] Use 'following or later' instead of 'below' for versions or orientation within a document. Use 'above' and 'below' only for physical space or screen descriptions.", "location": {"path": "_migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md", "range": {"start": {"line": 31, "column": 68}}}, "severity": "WARNING"}
8. When running metadata migration, run with the additional parameter `console metadata migrate --transformer-config-file /shared-logs-output/transformation.json`.[^1]

Check failure on line 32 in _migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [Vale.Terms] Use 'JSON' instead of 'json'. Raw Output: {"message": "[Vale.Terms] Use 'JSON' instead of 'json'.", "location": {"path": "_migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md", "range": {"start": {"line": 32, "column": 158}}}, "severity": "ERROR"}
9. If the transformation configuration is updated, backfill/replayer will need to be stopped and restarted to apply the changes.

[^1]: The `/shared-logs-output` mount will soon be relocated with a new mountpoint on the container for the EFS volume.

Check failure on line 35 in _migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [OpenSearch.Spelling] Error: mountpoint. If you are referencing a setting, variable, format, function, or repository, surround it with tic marks. Raw Output: {"message": "[OpenSearch.Spelling] Error: mountpoint. If you are referencing a setting, variable, format, function, or repository, surround it with tic marks.", "location": {"path": "_migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md", "range": {"start": {"line": 35, "column": 73}}}, "severity": "ERROR"}

### Configuration Options

Check failure on line 37 in _migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [OpenSearch.HeadingCapitalization] 'Configuration Options' is a heading and should be in sentence case. Raw Output: {"message": "[OpenSearch.HeadingCapitalization] 'Configuration Options' is a heading and should be in sentence case.", "location": {"path": "_migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md", "range": {"start": {"line": 37, "column": 5}}}, "severity": "ERROR"}

The TypeMappingsSanitizationTransformer supports several strategies for handling type mappings:

1. **Route to Separate Indices**: Split different types into their own indices

Check failure on line 41 in _migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [OpenSearch.SubstitutionsError] Use 'indexes' instead of 'Indices'. Raw Output: {"message": "[OpenSearch.SubstitutionsError] Use 'indexes' instead of 'Indices'.", "location": {"path": "_migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md", "range": {"start": {"line": 41, "column": 24}}}, "severity": "ERROR"}

Check failure on line 41 in _migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [OpenSearch.SubstitutionsError] Use 'indexes' instead of 'indices'. Raw Output: {"message": "[OpenSearch.SubstitutionsError] Use 'indexes' instead of 'indices'.", "location": {"path": "_migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md", "range": {"start": {"line": 41, "column": 72}}}, "severity": "ERROR"}
2. **Merge Types**: Combine multiple types into a single index
3. **Drop Types**: Selectively migrate only specific types
4. **Keep Original Structure**: Maintain the same index name while conforming to new type standards

### Example Configurations

Here are some common scenarios and their corresponding configurations:

#### 1. Route Different Types to Separate Indices

If you have an index `activity` with types `user` and `post` that you want to split into separate indices:

```json
[
{
"TypeMappingsSanitizationTransformerProvider": {
"staticMappings": {
"activity": {
"user": "new_users",
"post": "new_posts"
}
},
"sourceProperties": {
"version": {
"major": 6,
"minor": 8
}
}
}
}
]
```

This will:
- Route documents with type `user` to the `new_users` index
- Route documents with type `post` to the `new_posts` index

#### 2. Merge All Types into One Index

To combine multiple types into a single index:

```json
[
{
"TypeMappingsSanitizationTransformerProvider": {
"staticMappings": {
"activity": {
"user": "combined_activity",
"post": "combined_activity"
}
},
"sourceProperties": {
"version": {
"major": 6,
"minor": 8
}
}
}
}
]
```

#### 3. Drop Specific Types

To migrate only specific types and drop others:

```json
[
{
"TypeMappingsSanitizationTransformerProvider": {
"staticMappings": {
"activity": {
"user": "users_only",
}
},
"sourceProperties": {
"version": {
"major": 6,
"minor": 8
}
}
}
}
]
```
This configuration will only migrate documents of type `user` and ignore other types in the `activity` index.

### 4. Keep original structure

To migrate only specific types and keep the original structure:

```json
[
{
"TypeMappingsSanitizationTransformerProvider": {
"regexMappings": [
[
"(.*)",
".*",
"$1"
]
],
"sourceProperties": {
"version": {
"major": 6,
"minor": 8
}
}
}
}
]
```

This is equivalent to the merge all types into one index rule but using a pattern-based routing strategy.

### Defaults

When no regex mappings are specified, the transformer will default to the following behavior:

```json
{
"regexMappings": [
["(.+)", "_doc", "$1"],
["(.+)", "(.+)", "$1_$2"]
],
}
```

This has the effect of retaining the index name for es 6+ created indices while comibining the type and index name for es 5.x created indices. If you wish to retain the index name for es 5.x created indices, please use the `staticMappings` option or override the type mappings using the `regexMappings` option similar to the `Keep original structure`

Check warning on line 170 in _migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [OpenSearch.Please] Using 'please' is unnecessary. Remove. Raw Output: {"message": "[OpenSearch.Please] Using 'please' is unnecessary. Remove.", "location": {"path": "_migration-assistant/migration-phases/planning-your-migration/handling-type-mapping-deprecation.md", "range": {"start": {"line": 170, "column": 209}}}, "severity": "WARNING"}

### Limitations

- The transformer cannot be used prior to Elasticsearch 6.x.
- Within the replayer, the transformer only supports a subset of requests that may be replayed with types, in particular:
- PUT/POST /{index}/{type}/{id}
- PUT/POST /{index}/{type}/
- GET /{index}/{type}/{id}
- PUT/POST /_bulk
- PUT/POST /{index}
- Within the replayer, create index split is not supported.
- Note: This is only impactful on ES 5.x since multi type index creation is not supported on ES 6.x.

### Important Notes

- After ES 6, documents either have no type or are forced to use the type `_doc`
- When migrating from ES 6, some type context might not be available (e.g., during RFS operations)
- The transformer can handle both explicit type mappings and pattern-based routing
- Changes to the transformation configuration require restarting backfill/replayer operations

0 comments on commit 929c53e

Please sign in to comment.