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

Block Mapping on Reserved Field #35389

Closed
pickypg opened this issue Nov 8, 2018 · 3 comments · Fixed by #90989
Closed

Block Mapping on Reserved Field #35389

pickypg opened this issue Nov 8, 2018 · 3 comments · Fixed by #90989
Labels
>bug :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch

Comments

@pickypg
Copy link
Member

pickypg commented Nov 8, 2018

When trying to change the behavior of certain reserved fields, a user may be tempted to try to change their mapping:

PUT my_index
{
  "mappings": {
    "_doc": {
      "_field_names": {
        "type": "keyword"
      }
    }
  }
}

This doesn't work (it remains mapped as text in this case, which coincidentally seems wrong), but the request is accepted. When fetching the mapping, this attempted alteration does not exist in the response.

Relates to #8143.

@pickypg pickypg added >bug :Search Foundations/Mapping Index mappings, including merging and defining field types labels Nov 8, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@pickypg
Copy link
Member Author

pickypg commented Nov 8, 2018

As a side note, if you try to put it into the properties section of the type, then it does properly reject the field with Field [_field_names] is defined twice in [_doc].

It seems like we need to become a little stricter about unknown fields outside of the properties block.

@jtibshirani
Copy link
Contributor

jtibshirani commented Jun 4, 2019

Thanks @pickypg for reporting this and sorry for the very late response! I dug a bit into this behavior and had a few clarifications:

  • The correct way to configure _field_names is indeed outside the properties block (https://www.elastic.co/guide/en/elasticsearch/reference/7.1/mapping-field-names-field.html). We correctly reject invalid fields outside the properties block, returning the error ""Root mapping definition has unsupported parameters: ..."
  • As you noted, it is not possible to update metadata field mappings, as we throw an error of the form "Field ... is defined twice in ...".

I think a big reason your original example caused confusion is that we accept "type": "keyword" in the _field_names configuration, even though this is not a valid argument. This bug seems to be specific to the 'type' key, since we correctly reject other invalid keys. I'll open a PR to fix this leniency.

@rjernst rjernst added the Team:Search Meta label for search team label May 4, 2020
javanna added a commit to javanna/elasticsearch that referenced this issue Oct 18, 2022
The parsing code for metadata fields historically inherits from the existing parsing code
for fields in the mappings, where type is the one parameter that every field type accepts.
As a consequence, the metadata field definition has been silently ignoring the type parameter,
despite the type of metadata fields can never be changed. Furthermore, with the recent move
to parsing through builders (elastic#59847), we've been accepting other unsupported parameters like
fields, copy_to and boost.

This commit refactors the parsing method for metadata field builders to not reuse the base logic
but a rather simplified version. In the case of type, fields, copy_to and boost we issue a
deprecation warning starting from indices created on 8.6

Closes elastic#35389
javanna added a commit that referenced this issue Nov 16, 2022
…ta field definition (#90989)

The parsing code for metadata fields historically inherits from the existing parsing code for fields in the mappings, where type is the one parameter that every field type accepts. As a consequence, the metadata field definition has been silently ignoring the type parameter, despite the type of metadata fields can never be changed. Furthermore, with the recent move to parsing through builders (#59847), we've been accepting other unsupported parameters like fields, copy_to and boost.

This commit refactors the parsing method for metadata field builders to not reuse the base logic but a rather simplified version. In the case of type, fields, copy_to and boost we issue a deprecation warning starting from indices created on 8.6.

Closes #35389
@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
>bug :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
5 participants