Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support to remove aliases from index mappings #36418

Closed
ruflin opened this issue Dec 10, 2018 · 14 comments
Closed

Support to remove aliases from index mappings #36418

ruflin opened this issue Dec 10, 2018 · 14 comments
Labels
>enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch

Comments

@ruflin
Copy link
Contributor

ruflin commented Dec 10, 2018

Today it's possible to add an alias to an index mapping:

PUT foo
{
  "mappings": {
    "_doc": {
      "properties": {
        "a": {
          "type": "keyword"
        }
      }
    }
  }
}

After adding an alias it's not possible AFAIK to remove it. This would be useful if someone applies aliases to many indices and then realises it was the wrong field and wants to change it.

To my surprise it is possible to modify existing aliases by adding the same mapping again with a different path. This is great and already allows to handle the case where the wrong path was set by mistake but the alias name is correct.

@colings86 colings86 added the :Data Management/Indices APIs APIs to create and manage indices and templates label Dec 10, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features

@colings86
Copy link
Contributor

I'm not sure about allowing this. Mapping updates are today only additive and this prevents a lot of issues (we actually used to have the ability to remove a mapping type but that caused issues and so we removed it). The problems this could cause are not just limited to within Elasticsearch either. Applications using Elasticsearch rely on mappings and would now need to account for the fact that a field may disappear from the mapping at any time meaning that caching the fields for an index (Kibana for example does this in its index patterns) would be a lot harder.

@bleskes
Copy link
Contributor

bleskes commented Dec 10, 2018

I'm not per se supportive of the issue and I can see the points that @colings86 made but I want to add some color to this, to make sure the impact is understood (@ruflin please correct me if I misread where you're coming from).

The current plan is to heavily rely on field aliases to help the migration from 6.x non-ECS fields (Elastic Common Schema) to 7.x ECS based mappings. Currently we plan to offer people an opt-in BWC layer that will added 6.x compatible field aliases to 7.x so people can query both 7.x and 6.x indices in one query/agg. The ability to remove aliases will allow for us to fix bugs / change things in existing aliases if needed.

@ruflin
Copy link
Contributor Author

ruflin commented Dec 11, 2018

It seems mappings are not purely additive as they can also be edited. Field alias mapping already today supports changing the path of an existing alias. I think that solves part of the problem that @bleskes described above. In case a user introduced an alias a and pointed it to b and realises it should have been pointed to c, it can be updated. The problem left is what if the user realises he doesn't need alias a anymore.

One use I have in mind here is that users have the 7.x aliases around during the time they have 6.x and 7.x data and at one point when they only have 7.x data want to get rid of all the aliases as they are not needed anymore.

@stacey-gammon I wonder if changing the path of an alias could have an affect on Kibana?

@jpountz
Copy link
Contributor

jpountz commented Dec 14, 2018

We discussed this issue in FixitFriday. In general we don't want to remove fields from the mappings without removing them as well from the index. We had some attempts in the past (eg. upon merge) but we eventually decided against removing fields due to the complexity and how it gave room for bugs including data corruption.

Field aliases are a bit different due to the fact that they don't store any data in the index, which might make removing aliases acceptable. Yet that would still come with a number of challenges, for instance it would be an issue for saved searches, eg. the percolator, since queries are indexed depending on how a field is mapped. If an alias was changed to point to a field of a different type, it would never match (either correctly or at all) again.

This might also be a high hanging fruit as I suspect that there are lots of places that rely on the fact that mappings are additive internally.

@ruflin
Copy link
Contributor Author

ruflin commented Dec 17, 2018

It is already possible today changing the path of an alias even if the field has a different type (see example below). Wouldn't that cause the same issue as described above?

PUT test
{
  "mappings": {
    "_doc": {
      "properties": {
        "a": {
          "type": "keyword"
        },
        "b": {
          "type": "long"
        },
        "c": {
          "type": "alias",
          "path": "a"
        }
      }
    }
  }
}

GET test

PUT test/_mapping/_doc
{
  "properties": {
    "c": {
      "type": "alias",
      "path": "b"
    }
  }
}

GET test

The alias first points to a keyword field and then to a long field on the second GET.

@jpountz
Copy link
Contributor

jpountz commented Dec 17, 2018

Indeed.

@jakelandis jakelandis added the :Search/Search Search-related issues that do not fall into other categories label Dec 20, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@jtibshirani jtibshirani added :Search Foundations/Mapping Index mappings, including merging and defining field types and removed :Search/Search Search-related issues that do not fall into other categories labels Dec 20, 2018
@jtibshirani
Copy link
Contributor

I'm removing the team-discuss label here, because I think we already discussed the considerations around deleting field aliases.

I opened a bug report for the percolator issue in #37212. I suggest we use that issue for a focused discussion around whether the path of a field alias should be updatable.

@javanna
Copy link
Member

javanna commented Jun 23, 2022

I think this one is no longer a high hanging fruit and would be automatically fixed by resolving #87969 .

@jtibshirani
Copy link
Contributor

@javanna sorry if I'm missing something, how will making field aliases a runtime field (#87969) automatically let aliases be deleted?

@javanna
Copy link
Member

javanna commented Jun 24, 2022

@jtibshirani fair question, maybe I should have expanded a bit. I was thinking that once we have a good answer for aliasing a field with a runtime field that does not require a script, given that runtime fields can be removed this issue is solved. But it is solved only for users that are using the new way and it remains for folks that have field aliases in their mappings. We should then discuss what to do about those.

Does this make more sense now?

@jtibshirani
Copy link
Contributor

Yes thanks, I didn't understand that runtime fields could be easily removed. Should we close this out in favor of #87969? It feels like the best path forward for field aliases.

@javanna
Copy link
Member

javanna commented Jun 27, 2022

makes sense, closing this in favour of #87969 .

@javanna javanna closed this as completed Jun 27, 2022
@javanna javanna added Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch and removed Team:Search Meta label for search team labels Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch
Projects
None yet
Development

No branches or pull requests