Skip to content

Commit

Permalink
Introduce an include_type_name constant (#37155)
Browse files Browse the repository at this point in the history
I started referring to this parameter name from various places in #37149 so I
think it's a good idea to simplify things by referring to a common constant.
  • Loading branch information
Christoph Büscher authored Jan 7, 2019
1 parent 12a105e commit d18c3d6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ public abstract class BaseRestHandler extends AbstractComponent implements RestH

private final LongAdder usageCount = new LongAdder();

/**
* Parameter that controls whether certain REST apis should include type names in their requests or responses.
* Note: Support for this parameter will be removed after the transition perido to typeless APIs.
*/
protected static final String INCLUDE_TYPE_NAME_PARAMETER = "include_type_name";

protected BaseRestHandler(Settings settings) {
// TODO drop settings from ctor
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public String getName() {

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
final boolean includeTypeName = request.paramAsBoolean("include_type_name", true);
final boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, true);
CreateIndexRequest createIndexRequest = new CreateIndexRequest(request.param("index"));
if (request.hasContent()) {
Map<String, Object> sourceAsMap = XContentHelper.convertToMap(request.content(), false, request.getXContentType()).v2();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
package org.elasticsearch.rest.action.admin.indices;

import com.carrotsearch.hppc.cursors.ObjectCursor;
import org.apache.logging.log4j.Logger;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest;
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
import org.elasticsearch.action.support.IndicesOptions;
Expand Down Expand Up @@ -85,7 +86,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
deprecationLogger.deprecated("Type exists requests are deprecated, as types have been deprecated.");
}

final boolean includeTypeName = request.paramAsBoolean("include_type_name", true);
final boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, true);
final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
final String[] types = request.paramAsStringArrayOrEmptyIfAll("type");
final GetMappingsRequest getMappingsRequest = new GetMappingsRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public String getName() {

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
final boolean includeTypeName = request.paramAsBoolean("include_type_name", true);
final boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, true);
PutMappingRequest putMappingRequest = putMappingRequest(Strings.splitStringByCommaToArray(request.param("index")));
final String type = request.param("type");
if (type != null && includeTypeName == false) {
Expand Down

0 comments on commit d18c3d6

Please sign in to comment.