From d4bc3b75dcb8754a2c1f58d2e525d2c91b47b238 Mon Sep 17 00:00:00 2001 From: Henning Andersen <33268011+henningandersen@users.noreply.github.com> Date: Wed, 19 Feb 2020 08:52:08 +0100 Subject: [PATCH] Reindex: allow comma separated source indices (#52044) Added ability to specify comma separated list of source indices without array. Also fixed so that empty string results in validation error rather than index does not exist. Closes #51949 --- .../index/reindex/ReindexRequest.java | 6 +-- .../index/reindex/ReindexRequestTests.java | 40 +++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java b/server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java index 65d1c3d73d3..bb7bbf277a3 100644 --- a/server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java +++ b/server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java @@ -406,7 +406,7 @@ public class ReindexRequest extends AbstractBulkIndexByScrollRequest source, String name) { Object value = source.remove(name); @@ -418,9 +418,9 @@ public class ReindexRequest extends AbstractBulkIndexByScrollRequest list = (List) value; return list.toArray(new String[list.size()]); } else if (value instanceof String) { - return new String[] {(String) value}; + return Strings.splitStringByCommaToArray((String) value); } else { - throw new IllegalArgumentException("Expected [" + name + "] to be a list of a string but was [" + value + ']'); + throw new IllegalArgumentException("Expected [" + name + "] to be a list or a string but was [" + value + ']'); } } diff --git a/server/src/test/java/org/elasticsearch/index/reindex/ReindexRequestTests.java b/server/src/test/java/org/elasticsearch/index/reindex/ReindexRequestTests.java index db7fdb097d8..b5ca4efcc4f 100644 --- a/server/src/test/java/org/elasticsearch/index/reindex/ReindexRequestTests.java +++ b/server/src/test/java/org/elasticsearch/index/reindex/ReindexRequestTests.java @@ -324,4 +324,44 @@ public class ReindexRequestTests extends AbstractBulkByScrollRequestTestCase