Create alias index that assigns alias names to fields in original index?

Hello,
I have a large index with very specific field mapping that would not be easy to change. We have an application the requires specific field names for the data it uses. For example our main index has a field "feature.name" and the application needs to use a field called "title" that would map to the value of "feature.name" in the original index.

I'm familiar with creating alias fields to reference other fields within the same index, however the required field names may change or may conflict in the future.

Is it possible to create a new index that merely acts as an alias for the original index, so that the new index could have the exact field names needed and just map to the fields in the original index?

Example:

  • Primary-Index (main index with all our data)
    • feature: { name: text }
  • New-Alias-Index (index that only points to fields in the Primary-Index)
    • title (alis for Primary-Index.feature.name)

So far I've come up with using a search template that includes all of the field mappings via scripted_fields, but I worry about the long term impact of this approach on scalability.

How harmful would this approach be?
for example:

{
    "query": {...},
    "knn": {...},
    "_source": false,
    "stored_fields": "_none_",
    "script_fields": {
        "title": {"script": {"source": "doc['feature.name.enum']"}},
        "data_id": {"script": {"source": "doc['data.version.enum']"}},
        ...
    }
}

No, Elasticsearch does not directly support creating an index alias that remaps fields from one name to another. However, you can achieve similar results by using Elasticsearch's ingest pipelines to rename fields during ingestion, reindexing data with a script to change field names, handling the mapping at the application level, or developing custom middleware to translate field names in queries and responses. Each approach has its own trade-offs and complexities.

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