From 8267a767471b143e5cc4a7ddf5f22e14fcb57172 Mon Sep 17 00:00:00 2001 From: kimchy Date: Tue, 31 May 2011 16:21:59 +0300 Subject: [PATCH] force the type to be set when using the put mapping API in Java --- .../admin/indices/mapping/put/PutMappingRequest.java | 8 +++++--- .../indices/mapping/put/PutMappingRequestBuilder.java | 6 +++--- .../test/SimpleAttachmentIntegrationTests.java | 8 ++++++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java index 2b0e2a808d8..88f67d149ea 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java @@ -76,6 +76,9 @@ public class PutMappingRequest extends MasterNodeOperationRequest { @Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; + if (mappingType == null) { + validationException = addValidationError("mapping type is missing", validationException); + } if (mappingSource == null) { validationException = addValidationError("mapping source is missing", validationException); } @@ -105,10 +108,9 @@ public class PutMappingRequest extends MasterNodeOperationRequest { } /** - * The type of the mappings. Not required since it can be defined explicitly within the mapping source. - * If it is not defined within the mapping source, then it is required. + * The type of the mappings. */ - public PutMappingRequest type(String mappingType) { + @Required public PutMappingRequest type(String mappingType) { this.mappingType = mappingType; return this; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/client/action/admin/indices/mapping/put/PutMappingRequestBuilder.java b/modules/elasticsearch/src/main/java/org/elasticsearch/client/action/admin/indices/mapping/put/PutMappingRequestBuilder.java index 76d1b07d0a2..4fc9cf79e49 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/client/action/admin/indices/mapping/put/PutMappingRequestBuilder.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/client/action/admin/indices/mapping/put/PutMappingRequestBuilder.java @@ -24,6 +24,7 @@ import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse; import org.elasticsearch.client.IndicesAdminClient; import org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder; +import org.elasticsearch.common.Required; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -44,10 +45,9 @@ public class PutMappingRequestBuilder extends BaseIndicesRequestBuilder