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

@Override
protected Collection<Class<? extends Plugin>> getMockPlugins(){
ArrayList<Class<? extends Plugin>> mocks = new ArrayList<>(super.getMockPlugins());
mocks.add(CustomAggregationPlugin.class);
return mocks;
}

2 - Test aggregation using client and Builder

SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
.addAggregation(new CustomAggregationBuilder("fred").field("field1"))
.execute().actionGet();

ends up throwing error:

Caused by: java.lang.IllegalArgumentException: Unknown NamedWriteable [org.elasticsearch.search.aggregations.AggregationBuilder] ...

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 !

Thanks
Nirmal

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.