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

Change prefer_v2_templates parameter to default to true #55489

Merged
merged 3 commits into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/reference/api-conventions.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ Returns:
"settings": {
"index.number_of_replicas": "1",
"index.number_of_shards": "1",
"index.prefer_v2_templates": "false",
"index.prefer_v2_templates": "true",
"index.creation_date": "1474389951325",
"index.uuid": "n6gzFZTgS664GUfx0Xrpjw",
"index.version.created": ...,
Expand Down Expand Up @@ -423,7 +423,7 @@ Returns:
"created": ...
},
"provided_name" : "twitter",
"prefer_v2_templates": "false"
"prefer_v2_templates": "true"
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions docs/reference/migration/migrate_8_0/settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,15 @@ In Elasticsearch 7.8.0, the following settings have been deprecated:

In future releases, it will not be possible to disable the APIs for Enrichment,
Flattened mappings, ILM, Monitoring, Rollup, SLM, SQL, Transforms, and Vectors.

[float]
==== The `prefer_v2_templates` parameter now defaults to `true`

In Elasticsearch 7.8.0 the `?prefer_v2_templates=true|false` parameter was introduced to allow
specifying whether to favor V1 or V2 templates when a new index is created. In 8.0 this now defaults
to `true`, meaning that V2 index templates will always take precedence if they match. V1 templates
will continue to be applied if no V2 index template matches the newly created index pattern.

The `?prefer_v2_templates` parameter is supported on the <<indices-create-index,Create Index>>,
<<docs-index_,Index>>, <<docs-bulk,Bulk>>, <<docs-update,Update>>, and
<<indices-rollover-index,Rollover>> APIs.
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public Iterator<Setting<?>> settings() {
// this is only setable internally not a registered setting!!
public static final String PREFER_V2_TEMPLATES_FLAG = "prefer_v2_templates";
public static final String SETTING_PREFER_V2_TEMPLATES = "index." + PREFER_V2_TEMPLATES_FLAG;
public static final Setting<Boolean> PREFER_V2_TEMPLATES_SETTING = Setting.boolSetting(SETTING_PREFER_V2_TEMPLATES, false,
public static final Setting<Boolean> PREFER_V2_TEMPLATES_SETTING = Setting.boolSetting(SETTING_PREFER_V2_TEMPLATES, true,
Property.Dynamic, Property.IndexScope);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void cleanup() throws Exception {

public void testCreateIndexPreference() throws Exception {
client().admin().indices().prepareCreate(INDEX).get();
assertUsedV1();
assertUsedV2();

client().admin().indices().create(new CreateIndexRequest(INDEX).preferV2Templates(false)).get();
assertUsedV1();
Expand All @@ -80,7 +80,7 @@ public void testCreateIndexPreference() throws Exception {

public void testIndexingRequestPreference() throws Exception {
client().index(new IndexRequest(INDEX).source("foo", "bar")).get();
assertUsedV1();
assertUsedV2();

client().index(new IndexRequest(INDEX).source("foo", "bar").preferV2Templates(false)).get();
assertUsedV1();
Expand All @@ -89,7 +89,7 @@ public void testIndexingRequestPreference() throws Exception {
assertUsedV2();

client().update(new UpdateRequest(INDEX, "1").doc("foo", "bar").docAsUpsert(true)).get();
assertUsedV1();
assertUsedV2();

client().update(new UpdateRequest(INDEX, "1").doc("foo", "bar").docAsUpsert(true).preferV2Templates(false)).get();
assertUsedV1();
Expand All @@ -98,7 +98,7 @@ public void testIndexingRequestPreference() throws Exception {
assertUsedV2();

client().bulk(new BulkRequest(INDEX).add(new IndexRequest(INDEX).source("foo", "bar"))).get();
assertUsedV1();
assertUsedV2();

client().bulk(new BulkRequest(INDEX).add(new IndexRequest(INDEX).source("foo", "bar")).preferV2Templates(false)).get();
assertUsedV1();
Expand All @@ -115,8 +115,8 @@ public void testRolloverMaintainsSetting() throws Exception {

client().admin().indices().prepareRolloverIndex("alias").get();
GetSettingsResponse resp = client().admin().indices().prepareGetSettings().setIndices(INDEX + "-000002").get();
assertThat("expected index to use V1 template and have priority of 15",
resp.getSetting(INDEX + "-000002", "index.priority"), equalTo("15"));
assertThat("expected index to use V2 template and have priority of 23",
resp.getSetting(INDEX + "-000002", "index.priority"), equalTo("23"));
client().admin().indices().prepareDelete(INDEX + "*").get();
}

Expand Down