diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexAction.java index 423dba222ea..7fc42dad276 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexAction.java @@ -45,7 +45,6 @@ import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.ccr.CcrSettings; import java.io.IOException; -import java.util.HashSet; import java.util.List; import java.util.Map; @@ -247,20 +246,21 @@ public class CreateAndFollowIndexAction extends Action cursor : leaderIndexMetaData.getMappings()) { imdBuilder.putMapping(cursor.value); } - mdBuilder.put(imdBuilder.build(), false); + imdBuilder.setRoutingNumShards(leaderIndexMetaData.getRoutingNumShards()); + IndexMetaData followIMD = imdBuilder.build(); + mdBuilder.put(followIMD, false); ClusterState.Builder builder = ClusterState.builder(currentState); builder.metaData(mdBuilder.build()); @@ -279,7 +281,10 @@ public class CreateAndFollowIndexAction extends Action assertExpectedDocumentRunnable(final int value) { return () -> { final GetResponse getResponse = client().prepareGet("index2", "doc", Integer.toString(value)).get(); - assertTrue("doc with id [" + value + "] does not exist", getResponse.isExists()); + assertTrue("Doc with id [" + value + "] is missing", getResponse.isExists()); assertTrue((getResponse.getSource().containsKey("f"))); assertThat(getResponse.getSource().get("f"), equalTo(value)); };