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

Remove prefer_v2_templates query string parameter #56545

Merged
merged 2 commits into from
May 11, 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
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