diff --git a/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java b/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java index 358cc4eaa7c..c28ad551fbc 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java @@ -107,7 +107,7 @@ public class TransportClearIndicesCacheAction extends TransportBroadcastOperatio } @Override - protected ShardClearIndicesCacheRequest newShardRequest(ShardRouting shard, ClearIndicesCacheRequest request) { + protected ShardClearIndicesCacheRequest newShardRequest(int numShards, ShardRouting shard, ClearIndicesCacheRequest request) { return new ShardClearIndicesCacheRequest(shard.index(), shard.id(), request); } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java b/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java index 02dc414dec0..dd899a8fcb4 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java @@ -99,7 +99,7 @@ public class TransportFlushAction extends TransportBroadcastOperationAction percolateQueries; + private final int numberOfShards; private String[] types; private Engine.Searcher docSearcher; @@ -127,6 +128,7 @@ public class PercolateContext extends SearchContext { this.engineSearcher = indexShard.acquireSearcher("percolate"); this.searcher = new ContextIndexSearcher(this, engineSearcher); this.scriptService = scriptService; + this.numberOfShards = request.getNumberOfShards(); } public IndexSearcher docSearcher() { @@ -327,7 +329,7 @@ public class PercolateContext extends SearchContext { @Override public int numberOfShards() { - throw new UnsupportedOperationException(); + return numberOfShards; } @Override diff --git a/src/test/java/org/elasticsearch/percolator/PercolatorFacetsAndAggregationsTests.java b/src/test/java/org/elasticsearch/percolator/PercolatorFacetsAndAggregationsTests.java index ab1c77a579c..8e959b584c4 100644 --- a/src/test/java/org/elasticsearch/percolator/PercolatorFacetsAndAggregationsTests.java +++ b/src/test/java/org/elasticsearch/percolator/PercolatorFacetsAndAggregationsTests.java @@ -37,6 +37,7 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchQuery; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertMatchCount; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; import static org.hamcrest.Matchers.arrayWithSize; import static org.hamcrest.Matchers.equalTo; @@ -122,4 +123,16 @@ public class PercolatorFacetsAndAggregationsTests extends ElasticsearchIntegrati } } + @Test + public void testSignificantAggs() throws Exception { + client().admin().indices().prepareCreate("test").execute().actionGet(); + ensureGreen(); + PercolateRequestBuilder percolateRequestBuilder = client().preparePercolate() + .setIndices("test").setDocumentType("type") + .setPercolateDoc(docBuilder().setDoc(jsonBuilder().startObject().field("field1", "value").endObject())) + .addAggregation(AggregationBuilders.significantTerms("a").field("field2")); + PercolateResponse response = percolateRequestBuilder.get(); + assertNoFailures(response); + } + }