Skip to content

Deprecate timestamp and ttl on index requests. #21826

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

Merged
merged 1 commit into from
Nov 29, 2016
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 @@ -340,8 +340,10 @@ public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Null
} else if ("_parent".equals(currentFieldName) || "parent".equals(currentFieldName)) {
parent = parser.text();
} else if ("_timestamp".equals(currentFieldName) || "timestamp".equals(currentFieldName)) {
DEPRECATION_LOGGER.deprecated("The [timestamp] parameter of index requests is deprecated");
timestamp = parser.text();
} else if ("_ttl".equals(currentFieldName) || "ttl".equals(currentFieldName)) {
DEPRECATION_LOGGER.deprecated("The [ttl] parameter of index requests is deprecated");
if (parser.currentToken() == XContentParser.Token.VALUE_STRING) {
ttl = TimeValue.parseTimeValue(parser.text(), null, currentFieldName);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,18 +331,21 @@ public String parent() {
/**
* Sets the timestamp either as millis since the epoch, or, in the configured date format.
*/
@Deprecated
public IndexRequest timestamp(String timestamp) {
this.timestamp = timestamp;
return this;
}

@Deprecated
public String timestamp() {
return this.timestamp;
}

/**
* Sets the ttl value as a time value expression.
*/
@Deprecated
public IndexRequest ttl(String ttl) {
this.ttl = TimeValue.parseTimeValue(ttl, null, "ttl");
return this;
Expand All @@ -351,6 +354,7 @@ public IndexRequest ttl(String ttl) {
/**
* Sets the ttl as a {@link TimeValue} instance.
*/
@Deprecated
public IndexRequest ttl(TimeValue ttl) {
this.ttl = ttl;
return this;
Expand All @@ -359,6 +363,7 @@ public IndexRequest ttl(TimeValue ttl) {
/**
* Sets the relative ttl value in milliseconds. It musts be greater than 0 as it makes little sense otherwise.
*/
@Deprecated
public IndexRequest ttl(long ttl) {
this.ttl = new TimeValue(ttl);
return this;
Expand All @@ -367,6 +372,7 @@ public IndexRequest ttl(long ttl) {
/**
* Returns the ttl as a {@link TimeValue}
*/
@Deprecated
public TimeValue ttl() {
return this.ttl;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ public IndexRequestBuilder setVersionType(VersionType versionType) {
/**
* Sets the timestamp either as millis since the epoch, or, in the configured date format.
*/
@Deprecated
public IndexRequestBuilder setTimestamp(String timestamp) {
request.timestamp(timestamp);
return this;
Expand All @@ -241,6 +242,7 @@ public IndexRequestBuilder setTimestamp(String timestamp) {
/**
* Sets the ttl value as a time value expression.
*/
@Deprecated
public IndexRequestBuilder setTTL(String ttl) {
request.ttl(ttl);
return this;
Expand All @@ -249,6 +251,7 @@ public IndexRequestBuilder setTTL(String ttl) {
/**
* Sets the relative ttl value in milliseconds. It musts be greater than 0 as it makes little sense otherwise.
*/
@Deprecated
public IndexRequestBuilder setTTL(long ttl) {
request.ttl(ttl);
return this;
Expand All @@ -257,6 +260,7 @@ public IndexRequestBuilder setTTL(long ttl) {
/**
* Sets the ttl as a {@link TimeValue} instance.
*/
@Deprecated
public IndexRequestBuilder setTTL(TimeValue ttl) {
request.ttl(ttl);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ public UpdateRequestBuilder setScriptedUpsert(boolean scriptedUpsert) {
* and the source of the document isn't changed then the ttl update won't take
* effect.
*/
@Deprecated
public UpdateRequestBuilder setTtl(Long ttl) {
request.doc().ttl(ttl);
return this;
Expand All @@ -370,6 +371,7 @@ public UpdateRequestBuilder setTtl(Long ttl) {
* and the source of the document isn't changed then the ttl update won't take
* effect.
*/
@Deprecated
public UpdateRequestBuilder setTtl(String ttl) {
request.doc().ttl(ttl);
return this;
Expand All @@ -380,6 +382,7 @@ public UpdateRequestBuilder setTtl(String ttl) {
* and the source of the document isn't changed then the ttl update won't take
* effect.
*/
@Deprecated
public UpdateRequestBuilder setTtl(TimeValue ttl) {
request.doc().ttl(ttl);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
IndexRequest indexRequest = new IndexRequest(request.param("index"), request.param("type"), request.param("id"));
indexRequest.routing(request.param("routing"));
indexRequest.parent(request.param("parent")); // order is important, set it after routing, so it will set the routing
if (request.hasParam("timestamp")) {
deprecationLogger.deprecated("The [timestamp] parameter of index requests is deprecated");
}
indexRequest.timestamp(request.param("timestamp"));
if (request.hasParam("ttl")) {
deprecationLogger.deprecated("The [ttl] parameter of index requests is deprecated");
indexRequest.ttl(request.param("ttl"));
}
indexRequest.setPipeline(request.param("pipeline"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
updateRequest.version(RestActions.parseVersion(request));
updateRequest.versionType(VersionType.fromString(request.param("version_type"), updateRequest.versionType()));

if (request.hasParam("timestamp")) {
deprecationLogger.deprecated("The [timestamp] parameter of index requests is deprecated");
}
if (request.hasParam("ttl")) {
deprecationLogger.deprecated("The [ttl] parameter of index requests is deprecated");
}

// see if we have it in the body
if (request.hasContent()) {
Expand Down