Integration Testing Aggregation Plugin

I was trying to get my custom Aggregation Plugin work with ESIntegTestCase derived Test . Not sure how to get the Plugin registered properly for test to work .. I'm able to get the aggregation working fine with REST API , but not sure how to wire a plugin based aggregation to TranportClient.

1 - Registered plugin by overriding getMockPlugins

protected Collection<Class<? extends Plugin>> getMockPlugins(){
ArrayList<Class<? extends Plugin>> mocks = new ArrayList<>(super.getMockPlugins());
return mocks;

2 - Test aggregation using client and Builder

SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.addAggregation(new CustomAggregationBuilder("fred").field("field1"))

ends up throwing error:

Caused by: java.lang.IllegalArgumentException: Unknown NamedWriteable [] ...

AFAIK - SearchModule does register NamedWritable in case plugin was registered just like it does for main cluster, but not sure how to get that done in TransportClient

Appreciate any help !


Ah - there was an override :slight_smile:

protected Collection<Class<? extends Plugin>> transportClientPlugins() {

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.