Skip to content

Commit

Permalink
Remove prefer_v2_templates query string parameter
Browse files Browse the repository at this point in the history
This commit removes the `prefer_v2_templates` flag and setting. This was a brief setting that
allowed specifying whether V1 or V2 template should be used when an index is created. It has been
removed in favor of V2 templates always having priority.

Relates to elastic#53101
Resolves elastic#56528

This is not a breaking change because this flag was never in a released version.
  • Loading branch information
dakrone committed May 11, 2020
1 parent b90c7e3 commit 9675bd0
Show file tree
Hide file tree
Showing 37 changed files with 32 additions and 526 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ static Request createIndex(CreateIndexRequest createIndexRequest) throws IOExcep
parameters.withTimeout(createIndexRequest.timeout());
parameters.withMasterTimeout(createIndexRequest.masterNodeTimeout());
parameters.withWaitForActiveShards(createIndexRequest.waitForActiveShards());
if (createIndexRequest.preferV2Templates() != null) {
parameters.putParam(IndexMetadata.PREFER_V2_TEMPLATES_FLAG, Boolean.toString(createIndexRequest.preferV2Templates()));
}
request.addParameters(parameters.asMap());
request.setEntity(RequestConverters.createEntity(createIndexRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
return request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import org.elasticsearch.client.security.RefreshPolicy;
import org.elasticsearch.client.tasks.TaskId;
import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.Priority;
import org.elasticsearch.common.Strings;
Expand Down Expand Up @@ -134,9 +133,6 @@ static Request bulk(BulkRequest bulkRequest) throws IOException {
parameters.withRefreshPolicy(bulkRequest.getRefreshPolicy());
parameters.withPipeline(bulkRequest.pipeline());
parameters.withRouting(bulkRequest.routing());
if (bulkRequest.preferV2Templates() != null) {
parameters.putParam(IndexMetadata.PREFER_V2_TEMPLATES_FLAG, Boolean.toString(bulkRequest.preferV2Templates()));
}
// Bulk API only supports newline delimited JSON or Smile. Before executing
// the bulk, we need to check that all requests have the same content-type
// and this content-type is supported by the Bulk API.
Expand Down Expand Up @@ -350,9 +346,6 @@ static Request index(IndexRequest indexRequest) {
parameters.withPipeline(indexRequest.getPipeline());
parameters.withRefreshPolicy(indexRequest.getRefreshPolicy());
parameters.withWaitForActiveShards(indexRequest.waitForActiveShards());
if (indexRequest.preferV2Templates() != null) {
parameters.putParam(IndexMetadata.PREFER_V2_TEMPLATES_FLAG, Boolean.toString(indexRequest.preferV2Templates()));
}

BytesRef source = indexRequest.source().toBytesRef();
ContentType contentType = createContentType(indexRequest.getContentType());
Expand Down Expand Up @@ -381,9 +374,6 @@ static Request update(UpdateRequest updateRequest) throws IOException {
parameters.withRetryOnConflict(updateRequest.retryOnConflict());
parameters.withVersion(updateRequest.version());
parameters.withVersionType(updateRequest.versionType());
if (updateRequest.preferV2Templates() != null) {
parameters.putParam(IndexMetadata.PREFER_V2_TEMPLATES_FLAG, Boolean.toString(updateRequest.preferV2Templates()));
}

// The Java API allows update requests with different content types
// set for the partial document and the upsert document. This client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.elasticsearch.action.support.ActiveShardCount;
import org.elasticsearch.client.TimedRequest;
import org.elasticsearch.client.Validatable;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesArray;
Expand Down Expand Up @@ -63,7 +62,6 @@ public class CreateIndexRequest extends TimedRequest implements Validatable, ToX

private BytesReference mappings;
private XContentType mappingsXContentType;
private Boolean preferV2Templates;

private final Set<Alias> aliases = new HashSet<>();

Expand Down Expand Up @@ -267,16 +265,6 @@ public CreateIndexRequest aliases(Collection<Alias> aliases) {
return this;
}

public CreateIndexRequest preferV2Templates(Boolean preferV2Templates) {
this.preferV2Templates = preferV2Templates;
return this;
}

@Nullable
public Boolean preferV2Templates() {
return this.preferV2Templates;
}

/**
* Sets the settings and mappings as a single source.
*
Expand Down
4 changes: 1 addition & 3 deletions docs/reference/api-conventions.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ Returns:
"settings": {
"index.number_of_replicas": "1",
"index.number_of_shards": "1",
"index.prefer_v2_templates": "false",
"index.creation_date": "1474389951325",
"index.uuid": "n6gzFZTgS664GUfx0Xrpjw",
"index.version.created": ...,
Expand Down Expand Up @@ -422,8 +421,7 @@ Returns:
"version": {
"created": ...
},
"provided_name" : "twitter",
"prefer_v2_templates": "false"
"provided_name" : "twitter"
}
}
}
Expand Down
8 changes: 3 additions & 5 deletions docs/reference/indices/index-templates.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ This documentation is about V2 (version 2) index templates. For V1 templates ple

[NOTE]
====
In {es} 7.8 the `prefer_v2_templates` querystring parameter was introduced to the index, update,
bulk, and create index APIs to allow configuring whether to favor V2 or V1 index templates. In 7.x
the default value for this parameter is `false` meaning that the <<indices-templates-v1,V1 index
templates>> take precedence. In 8.x the default value for the parameter is `true` meaning that V2
index templates take precedence (V1 templates may still match if no V2 template matches).
In {es} 7.8 V2 templates were introduced. When a V2 index template matches a given index it always
takes precedence over a V1 template. If no V2 index template matches, a V1 template may still match
and be applied.
====

An index template is a way to tell {es} how to configure an index when it is created. Templates are
Expand Down
8 changes: 3 additions & 5 deletions docs/reference/indices/templates.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ replaced by V2 templates. For information about V2 templates, see <<indices-temp

[NOTE]
====
In {es} 7.8 the `prefer_v2_templates` querystring parameter was introduced to the index, update,
bulk, and create index APIs to allow configuring whether to favor V2 or V1 index templates. In 7.x
the default value for this parameter is `false` meaning that the V1 index templates take precedence.
In 8.x the default value for the parameter is `true` meaning that <<indices-templates,V2 index
templates>> take precedence (V1 templates may still match if no V2 template matches).
In {es} 7.8 V2 templates were introduced. When a V2 index template matches a given index it always
takes precedence over a V1 template. If no V2 index template matches, a V1 template may still match
and be applied.
====

Creates or updates an index template.
Expand Down
4 changes: 0 additions & 4 deletions rest-api-spec/src/main/resources/rest-api-spec/api/bulk.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@
"pipeline":{
"type":"string",
"description":"The pipeline id to preprocess incoming documents with"
},
"prefer_v2_templates": {
"type": "boolean",
"description": "favor V2 templates instead of V1 templates during automatic index creation"
}
},
"body":{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@
"pipeline":{
"type":"string",
"description":"The pipeline id to preprocess incoming documents with"
},
"prefer_v2_templates": {
"type": "boolean",
"description": "favor V2 templates instead of V1 templates during automatic index creation"
}
},
"body":{
Expand Down
4 changes: 0 additions & 4 deletions rest-api-spec/src/main/resources/rest-api-spec/api/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,6 @@
"pipeline":{
"type":"string",
"description":"The pipeline id to preprocess incoming documents with"
},
"prefer_v2_templates": {
"type": "boolean",
"description": "favor V2 templates instead of V1 templates during automatic index creation"
}
},
"body":{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
"master_timeout":{
"type":"time",
"description":"Specify timeout for connection to master"
},
"prefer_v2_templates": {
"type": "boolean",
"description": "favor V2 templates instead of V1 templates during index creation"
}
},
"body":{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@
"wait_for_active_shards":{
"type":"string",
"description":"Set the number of active shards to wait for on the newly created rollover index before the operation returns."
},
"prefer_v2_templates": {
"type": "boolean",
"description": "favor V2 templates instead of V1 templates during automatic index creation"
}
},
"body":{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@
"if_primary_term":{
"type":"number",
"description":"only perform the update operation if the last operation that has changed the document has the specified primary term"
},
"prefer_v2_templates": {
"type": "boolean",
"description": "favor V2 templates instead of V1 templates during automatic index creation"
}
},
"body":{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
- do:
indices.create:
index: bar-baz
prefer_v2_templates: true
body:
settings:
index.priority: 17
Expand Down Expand Up @@ -121,7 +120,6 @@

- do:
indices.create:
prefer_v2_templates: true
index: bar-baz

- do:
Expand Down Expand Up @@ -166,7 +164,6 @@

- do:
indices.create:
prefer_v2_templates: true
index: bazfoo

- do:
Expand Down Expand Up @@ -196,40 +193,10 @@

- do:
indices.create:
prefer_v2_templates: true
index: eggplant

- do:
indices.get:
index: eggplant

- match: {eggplant.settings.index.number_of_shards: "3"}

---
"Version 1 templates are preferred if the flag is set":
- skip:
version: " - 7.7.99"
reason: "index template v2 API unavailable before 7.8"
features: allowed_warnings

- do:
allowed_warnings:
- "index template [my-template] has index patterns [eggplant] matching patterns from existing older templates [global] with patterns (global => [*]); this template [my-template] will take precedence during new index creation"
indices.put_index_template:
name: my-template
body:
index_patterns: ["eggplant"]
template:
settings:
number_of_replicas: 2

- do:
indices.create:
prefer_v2_templates: false
index: eggplant

- do:
indices.get:
index: eggplant

- match: {eggplant.settings.index.number_of_replicas: "1"}
Loading

0 comments on commit 9675bd0

Please sign in to comment.