Mapping template field with keyword suffix


I am currently running into an issue where I am hitting the max fields for an index. In order to address this issue, I am defining mapping types for the different fields in my index. Many of the fields in my current index are string fields that are mapped both as text and keyword fields, but I really only need them to be mapped as keyword type.

Creating the new mapping to only map those fields as a keyword type is easy enough, however, I am looking for a way to make searching ACROSS both the new index and previous index without having to refactor all of my client code. The problem I am encountering is that the field is mapped as "foo.keyword" in the previous index, and would just be mapped as "foo" in the new index, if I provide a mapping definition for that field as something like:

"foo": {
    "type": "keyword",
    "ignore_above": 256

Ideally, what I am looking for is if there is some way to say the incoming field "foo" in the document should be mapped as a keyword to "foo.keyword", without being mapped as text at all.

Any advice would be greatly appreciated,

Welcome to our community! :smiley:
Does Alias field type | Elasticsearch Guide [7.12] | Elastic help?

Unfortunately, no. At least not directly. We would need to alias every single field in the old index, as well as every corresponding field in the new index in order to make this happen. It would incur a large amount of technical debt, for a small ROI.

It seems like the feature that I request is not available in Elastic (at least not that I can find). Perhaps my best option is create a new index with the updated mapping, and then import the old data into that index, so that the same client code can query across both the old field mapping and the new optimized field mapping.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.