diff --git a/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java index aae996b7fca..3f66ebd910b 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java @@ -256,7 +256,7 @@ public class CreateIndexRequest extends AcknowledgedRequest try { XContentBuilder builder = XContentFactory.jsonBuilder(); builder.map(source); - return aliases(builder.string()); + return aliases(builder.bytes()); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e); } @@ -266,19 +266,22 @@ public class CreateIndexRequest extends AcknowledgedRequest * Sets the aliases that will be associated with the index when it gets created */ public CreateIndexRequest aliases(XContentBuilder source) { - try { - return aliases(source.string()); - } catch (IOException e) { - throw new ElasticsearchIllegalArgumentException("Failed to build json for aliases", e); - } + return aliases(source.bytes()); } /** * Sets the aliases that will be associated with the index when it gets created */ public CreateIndexRequest aliases(String source) { + return aliases(new BytesArray(source)); + } + + /** + * Sets the aliases that will be associated with the index when it gets created + */ + public CreateIndexRequest aliases(BytesReference source) { try { - XContentParser parser = XContentHelper.createParser(new BytesArray(source)); + XContentParser parser = XContentHelper.createParser(source); //move to the first alias parser.nextToken(); while ((parser.nextToken()) != XContentParser.Token.END_OBJECT) { diff --git a/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilder.java b/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilder.java index e738ec3c855..9baca73b653 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilder.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestBuilder.java @@ -174,6 +174,14 @@ public class CreateIndexRequestBuilder extends AcknowledgedRequestBuilder