Skip to content

Ensure index.mapping.single_type can only be set on 5.x indices#25375

Merged
s1monw merged 10 commits intoelastic:masterfrom
s1monw:make_type_setting_private
Jul 5, 2017
Merged

Ensure index.mapping.single_type can only be set on 5.x indices#25375
s1monw merged 10 commits intoelastic:masterfrom
s1monw:make_type_setting_private

Conversation

@s1monw
Copy link
Copy Markdown
Contributor

@s1monw s1monw commented Jun 23, 2017

In 6.x we prevent multiple types and default to index.mapping.single_type: false
This change removes the registered setting and ensures that it's preserved for
5.x indices.

Relates to #24961

Note this might still fail since not all places are cut over

In 6.x we prevent multiple types and default to `index.mapping.single_type: false`
This change removes the registered setting and ensures that it's preserved for
5.x indices.

Relates to elastic#24961
@s1monw s1monw added :Core/Infra/Settings Settings infrastructure and APIs blocker v6.0.0 labels Jun 23, 2017
@s1monw s1monw requested review from jpountz and nik9000 June 23, 2017 10:03
Copy link
Copy Markdown
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM anytime the tests are ready for it.

case IndexSettings.INDEX_MAPPING_SINGLE_TYPE_SETTING_KEY:
// this was settable in 5.x but not anymore in 6.x so we have to preserve the value ie. make it read-only
// this can be removed in later versions
return true;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: extra indent.

private static MappedFieldType defaultFieldType(IndexSettings indexSettings) {
MappedFieldType defaultFieldType = Defaults.FIELD_TYPE.clone();
if (MapperService.INDEX_MAPPING_SINGLE_TYPE_SETTING.get(indexSettings)) {
if (indexSettings.isSingleType()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


@Before
public void setup() throws Exception {
indexService = createIndex("test", Settings.builder().put("mapping.single_type", false).build());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

- match: { hits.total: 5 } # just check we recovered fine


- do:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

s1monw added a commit to s1monw/elasticsearch that referenced this pull request Jun 24, 2017
This change removes the remaining explicitly specified `index.mapper.single_type`
settings from tests in order to allow the removal of the setting.
This is the already approved part of elastic#25375 broken out to simplfiy reviews on
s1monw added a commit that referenced this pull request Jun 25, 2017
…25388)

This change removes the remaining explicitly specified `index.mapper.single_type`
settings from tests in order to allow the removal of the setting.
This is the already approved part of #25375 broken out to simplfiy reviews on
Copy link
Copy Markdown
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jamshid
Copy link
Copy Markdown

jamshid commented Nov 15, 2019

Sorry I know this is closed but in case someone else ends up here from a web search...

Seems https://www.elastic.co/guide/en/elasticsearch/reference/6.7/removal-of-types.html falsely claims that index.mapping.single_type: true continues to work with 6.x. Not only is that the default value, but the PUT request is not allowed to specify this value.

The following examples can be used in Elasticsearch 5.6 or Elasticsearch 6.x. In 6.x, there is no need to specify index.mapping.single_type as that is the default.

This fails against ES 6.8.3 with a 400 error:

curl -X PUT -H 'Content-type: application/json' http://ELASTICSEARCH:9200/index1 --data-binary '
{
  "settings": {
    "index.mapping.single_type": true
  },
  "mappings": {
    "_doc": {
      "properties": {
        "name": {
          "type": "text"
        },
        "user_name": {
          "type": "keyword"
        },
        "email": {
          "type": "keyword"
        }
      }
    }
  }
}
'

HTTP/1.1 400 Bad Request
Warning: 299 Elasticsearch-6.8.3-0c48c0e "[types removal] The parameter include_type_name should be explicitly specified in create index requests to prepare for 7.0. In 7.0 include_type_name will default to 'false', and requests are expected to omit the type name in mapping definitions."
content-type: application/json; charset=UTF-8
content-length: X
{
  "error": {
    "root_cause": [
      {
        "type": "remote_transport_exception",
        "reason": "[...][indices:admin/create]"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "unknown setting [index.mapping.single_type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
  },
  "status": 400
}

I tried adding ?include_type_name=true to the url, the docs indicate that's needed for some other backward compatibility, but it does not help.

PS: having to add a parameter for a release, then remove it for the next release, makes it hard for an app to support multiple ES versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocker :Core/Infra/Settings Settings infrastructure and APIs v6.0.0-beta1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants