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

It is not clear why templates with a default mapping created prior to 7.x fail in 7.x #48427

Closed
talevy opened this issue Oct 23, 2019 · 6 comments
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

@talevy
Copy link
Contributor

talevy commented Oct 23, 2019

Problem

It is not clear how to resolve templates with default mappings in 7.x.

Indices created in 7.x matching templates created with the default mapping in 6.x fail to create
with following exception:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "The [default] mapping cannot be updated on index [my_index]: defaults mappings are not useful anymore now that indices can have at most one type."
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "The [default] mapping cannot be updated on index [my_index]: defaults mappings are not useful anymore now that indices can have at most one type."
  },
  "status" : 400
}

This error makes it clear that there is something wrong with the mapping, which results in users exploring templates for default-mapping usage. The problem is that users will not see their templates defining the _default_ mapping since 7.x defaults to the typeless APIs. So include_type_name=true must be set on the GET Templates API to see this information.

A Few Possible Solutions

  • specify how to take action in the error message
  • document this breaking change better in the docs
  • add better template upgrade support in the Upgrade Assistant (outside scope of this repository)
@talevy talevy added >bug :Search Foundations/Mapping Index mappings, including merging and defining field types v7.4.2 labels Oct 23, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Mapping)

@praveenmak
Copy link

I am seeing the same error after upgrading to 7.4.2 from 6.4.2

I get this when I do a rollover. I am using alias and we rollover to new one using URL math.

May I know what is the fix ?

@freakingid
Copy link

Greetings. I ran in to this as well. Please see:
Goodbye, types. Hello, typeless

Under "Stop using default mappings"

You should update your index templates and your application code to add these mappings to the actual type, rather than include them in a default mapping. If the name of the type is not important for you, the recommendation is to use _doc, which will make the transition to typeless APIs easier in the future.

@jeethsam
Copy link

jeethsam commented Apr 6, 2020

I ran into the same issue. Is there a fix for this apart from 'not using default mapping'?

@jtibshirani
Copy link
Contributor

As @freakingid mentioned, in 7.x you must remove the default mapping from index templates. No other fix is necessary.

To clarify one aspect that can be confusing -- issuing a normal 'get templates' call in 7.x won't show the default mapping, even if it's defined. To see all mappings that are defined, including the default mapping, you should pass the include_type_name parameter:

GET /_template/my_template?include_type_name

@jtibshirani
Copy link
Contributor

I merged #54915 to add debugging information to the migration docs. It also updates the error message to link to those docs.

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
Development

No branches or pull requests

7 participants