Transform string fields to text/keyword
This guide explains how Migration Assistant automatically handles the deprecated string field type during migration from earlier Elasticsearch versions.
Overview
The string field type was the primary text field type in early versions of Elasticsearch but was deprecated in Elasticsearch 5.x and completely removed in Elasticsearch 6.0. In Elasticsearch 5.x, it remained available in backward compatibility mode only.
When migrating from Elasticsearch 1.x through 5.x to later versions, Migration Assistant automatically converts string field types to their modern equivalents: text for analyzed fields and keyword for non-analyzed fields.
To determine whether an Elasticsearch cluster uses string field types, make a call to your source cluster’s GET /_mapping API. In the migration console, run console clusters curl source_cluster "/_mapping". If you see "type":"string", then this transformation is applicable and these fields will be automatically transformed during migration.
Compatibility
The string to text/keyword field type transformation applies to:
- Source clusters: Elasticsearch 1.x–5.x
- Target clusters: Elasticsearch 5.x+ or OpenSearch 1.x+
- Automatic conversion: No configuration required during metadata migrations.
Automatic conversion logic
Migration Assistant determines whether to convert a string field to text or keyword based on the field’s index property.
Conversion to keyword
Fields are converted to keyword when:
index: "not_analyzed"index: "no"index: false
Conversion to text
Fields are converted to text when:
index: "analyzed"indexis undefined
Property cleanup
During conversion, Migration Assistant also cleans up properties that are incompatible with the target field type.
For keyword fields, the following properties are removed:
analyzersearch_analyzerposition_increment_gapterm_vectorfielddata
For text fields, the following properties are removed:
doc_valuesnull_value(if present)
Additionally, legacy index values are normalized:
index: "analyzed"andindex: "not_analyzed"are removed (Elasticsearch 5.x default istrue).index: "no"becomesindex: false.
Migration output
During the migration process, you’ll see this transformation in the output:
Transformations:
string to text/keyword:
Convert field type string to text/keyword based on field data mappings
Transformation behavior
| Source field type | Target field type |
|---|---|
| |
| |
Behavior differences
Migration Assistant automatically converts all string fields during metadata migration. No additional configuration is required.
Mixed field types
If your source cluster already contains a mix of string, text, and keyword fields (common in Elasticsearch 5.x with restored Elasticsearch 2.x indexes), only the string fields will be converted. Existing text and keyword fields remain unchanged.
Query and aggregation impacts
After migration, be aware of these key differences:
- Term queries work differently on
text(analyzed) andkeyword(exact match) fields. - Aggregations:
textfields cannot be used for aggregations unlessfielddatais enabled;keywordfields are aggregation ready. - Sorting:
textfields cannot be used for sorting by default;keywordfields support sorting. - Case sensitivity:
keywordfields are case sensitive;textfields depend on the analyzer.
Application compatibility
Review your application code for:
- Queries that expect the old
stringfield behavior. - Aggregations or sorting on fields now converted to
text. - Case-sensitive searches on fields now using
keyword.
For fields requiring both analyzed and exact-match capabilities, consider using multi-fields with both text and keyword mappings after migration.
Troubleshooting
If you encounter issues with string field conversion:
-
Verify source version – Ensure your source cluster is running Elasticsearch 1.x through 5.x.
- Check migration logs – Review the detailed migration logs for any warnings or errors:
tail /shared-logs-output/migration-console-default/*/metadata/*.log - Validate mappings – After migration, verify that the field types have been correctly converted:
GET /your-index/_mapping - Review field usage – Ensure that your application queries are compatible with the new field types. Queries that worked with
stringfields should continue to work withtextandkeywordfields, but some advanced features may behave differently.
Related documentation
- Transform field types documentation – Configure custom field type transformations.
- keyword field type documentation – Learn about keyword field type.
- text field type documentation – Learn about text field type.