diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/ping/broadcast/TransportBroadcastPingAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/ping/broadcast/TransportBroadcastPingAction.java index e1572739b08..ce350b68bab 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/ping/broadcast/TransportBroadcastPingAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/ping/broadcast/TransportBroadcastPingAction.java @@ -64,8 +64,8 @@ public class TransportBroadcastPingAction extends TransportBroadcastOperationAct return new BroadcastPingRequest(); } - @Override protected GroupShardsIterator shards(BroadcastPingRequest request, ClusterState clusterState) { - return clusterService.operationRouting().searchShards(clusterState, request.indices(), request.queryHint(), null, null); + @Override protected GroupShardsIterator shards(BroadcastPingRequest request, String[] concreteIndices, ClusterState clusterState) { + return clusterService.operationRouting().searchShards(clusterState, concreteIndices, request.queryHint(), null, null); } @Override protected BroadcastPingResponse newResponse(BroadcastPingRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java index 67509e385e6..7ed18f27f70 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java @@ -142,7 +142,7 @@ public class TransportClearIndicesCacheAction extends TransportBroadcastOperatio /** * The refresh request works against *all* shards. */ - @Override protected GroupShardsIterator shards(ClearIndicesCacheRequest request, ClusterState clusterState) { - return clusterState.routingTable().allShardsGrouped(request.indices()); + @Override protected GroupShardsIterator shards(ClearIndicesCacheRequest request, String[] concreteIndices, ClusterState clusterState) { + return clusterState.routingTable().allShardsGrouped(concreteIndices); } } \ No newline at end of file diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java index 17038da2370..a184b4536f7 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java @@ -118,7 +118,7 @@ public class TransportFlushAction extends TransportBroadcastOperationAction 0) { + filteringAliases = new String[aliasesSize]; + for (int i = 0; i < aliasesSize; i++) { + filteringAliases[i] = in.readUTF(); + } + } } @Override public void writeTo(StreamOutput out) throws IOException { @@ -115,5 +129,13 @@ class ShardCountRequest extends BroadcastShardOperationRequest { for (String type : types) { out.writeUTF(type); } + if (filteringAliases != null) { + out.writeVInt(filteringAliases.length); + for (String alias : filteringAliases) { + out.writeUTF(alias); + } + } else { + out.writeVInt(0); + } } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/count/TransportCountAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/count/TransportCountAction.java index a299bf1fa2f..f2158e3abbb 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/count/TransportCountAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/count/TransportCountAction.java @@ -75,19 +75,20 @@ public class TransportCountAction extends TransportBroadcastOperationAction listener) { this.request = request; this.listener = listener; @@ -150,11 +152,11 @@ public abstract class TransportBroadcastOperationAction checking filtering alias for two indices"); SearchResponse searchResponse = client1.prepareSearch("foos").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet(); assertHits(searchResponse.hits(), "1", "5"); + assertThat(client1.prepareCount("foos").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().count(), equalTo(2L)); logger.info("--> checking filtering alias for one index"); searchResponse = client1.prepareSearch("bars").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet(); assertHits(searchResponse.hits(), "2"); + assertThat(client1.prepareCount("bars").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().count(), equalTo(1L)); logger.info("--> checking filtering alias for two indices and one complete index"); searchResponse = client1.prepareSearch("foos", "test1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet(); assertHits(searchResponse.hits(), "1", "2", "3", "4", "5"); + assertThat(client1.prepareCount("foos", "test1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().count(), equalTo(5L)); logger.info("--> checking filtering alias for two indices and non-filtering alias for one index"); searchResponse = client1.prepareSearch("foos", "aliasToTest1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet(); assertHits(searchResponse.hits(), "1", "2", "3", "4", "5"); + assertThat(client1.prepareCount("foos", "aliasToTest1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().count(), equalTo(5L)); logger.info("--> checking filtering alias for two indices and non-filtering alias for both indices"); searchResponse = client1.prepareSearch("foos", "aliasToTests").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet(); assertThat(searchResponse.hits().totalHits(), equalTo(8L)); + assertThat(client1.prepareCount("foos", "aliasToTests").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().count(), equalTo(8L)); + + logger.info("--> checking filtering alias for two indices and non-filtering alias for both indices"); + searchResponse = client1.prepareSearch("foos", "aliasToTests").setQuery(QueryBuilders.termQuery("name", "something")).execute().actionGet(); + assertHits(searchResponse.hits(), "4", "8"); + assertThat(client1.prepareCount("foos", "aliasToTests").setQuery(QueryBuilders.termQuery("name", "something")).execute().actionGet().count(), equalTo(2L)); } @Test public void testSearchingFilteringAliasesMultipleIndices() throws Exception { @@ -290,21 +300,27 @@ public class IndexAliasesTests extends AbstractNodesTests { logger.info("--> checking filtering alias for multiple indices"); SearchResponse searchResponse = client1.prepareSearch("filter23", "filter13").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet(); assertHits(searchResponse.hits(), "21", "31", "13", "33"); + assertThat(client1.prepareCount("filter23", "filter13").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().count(), equalTo(4L)); searchResponse = client1.prepareSearch("filter23", "filter1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet(); assertHits(searchResponse.hits(), "21", "31", "11", "12", "13"); + assertThat(client1.prepareCount("filter23", "filter1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().count(), equalTo(5L)); searchResponse = client1.prepareSearch("filter13", "filter1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet(); assertHits(searchResponse.hits(), "11", "12", "13", "33"); + assertThat(client1.prepareCount("filter13", "filter1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().count(), equalTo(4L)); searchResponse = client1.prepareSearch("filter13", "filter1", "filter23").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet(); assertHits(searchResponse.hits(), "11", "12", "13", "21", "31", "33"); + assertThat(client1.prepareCount("filter13", "filter1", "filter23").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().count(), equalTo(6L)); searchResponse = client1.prepareSearch("filter23", "filter13", "test2").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet(); assertHits(searchResponse.hits(), "21", "22", "23", "31", "13", "33"); + assertThat(client1.prepareCount("filter23", "filter13", "test2").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().count(), equalTo(6L)); searchResponse = client1.prepareSearch("filter23", "filter13", "test1", "test2").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet(); assertHits(searchResponse.hits(), "11", "12", "13", "21", "22", "23", "31", "33"); + assertThat(client1.prepareCount("filter23", "filter13", "test1", "test2").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().count(), equalTo(8L)); }