# Upgrading from 2.X to 5.3.0 aggregation errors

**URL:** <https://discuss.elastic.co/t/upgrading-from-2-x-to-5-3-0-aggregation-errors/150622>\
**Category:** Elasticsearch\
**Created:** [October 1, 2018, 10:19pm UTC](https://discuss.elastic.co/t/upgrading-from-2-x-to-5-3-0-aggregation-errors/150622 "2018-10-01T22:19:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bdevaca](https://avatars.discourse-cdn.com/v4/letter/b/b9bd4f/32.png) [@bdevaca](https://discuss.elastic.co/u/bdevaca)\
**Post date:** [October 1, 2018, 10:19pm UTC](https://discuss.elastic.co/t/upgrading-from-2-x-to-5-3-0-aggregation-errors/150622/1 "2018-10-01T22:19:14Z")

</div>

here is my aggregation logic that works in 2.X

```
	String hostName = esUtilityService.getHostName();
	String clusterName = esUtilityService.getClusterName();
	String indexName = esUtilityService.getIndexName();
	//Settings settings = Settings.settingsBuilder().put("cluster.name", clusterName).build();
	Settings settings = Settings.builder().put("cluster.name", clusterName).build();
	
	Integer filterSize = result.getTotalCount();
	Client filterClient = null;
	
	try{

```

InetSocketTransportAddress(InetAddress.getByName(hostName), 9300));

```
		filterClient = new PreBuiltTransportClient(settings)
		.addTransportAddress(new InetSocketTransportAddress(InetAddress.getLocalHost(), 9300));
				
		SearchRequestBuilder requestBuilder = filterClient.prepareSearch(indexName);
		
		requestBuilder.setTypes(documentType);
		requestBuilder.setQuery(qb);
		requestBuilder.setFrom(0).setSize(0);
		requestBuilder.addAggregation(AggregationBuilders.stats("unitCostStats").field("unitCost"));
        requestBuilder.addAggregation(AggregationBuilders.terms("vendors").field("vendorId").size(0));
        
		SearchResponse filterResponse = requestBuilder.execute().actionGet();	
		processFiltersForDisplay(result, filterResponse);	

```

This is the error I see when starting the server:  
ERROR [2018-10-01 17:02:50,748] [localhost-startStop-1] (ContextLoader.java:358) [] - Context initialization failed  
java.lang.VerifyError: Bad type on operand stack  
Exception Details:  
Location:  
com/periscope/service/elastic/impl/ElasticPoItemServiceImpl.doFilterLogic(Lcom/periscope/viewHelper/catalog/Results;Lorg/elasticsearch/index/query/QueryBuilder;Ljava/lang/String;)V @153: invokevirtual  
Reason:  
Type 'org/elasticsearch/search/aggregations/bucket/terms/TermsAggregationBuilder' (current frame, stack[1]) is not assignable to 'org/elasticsearch/search/aggregations/AggregationBuilder'  
Current Frame:  
bci: @153  
flags: { }  
locals: { 'com/periscope/service/elastic/impl/ElasticPoItemServiceImpl', 'com/periscope/viewHelper/catalog/Results', 'org/elasticsearch/index/query/QueryBuilder', 'java/lang/String', 'java/lang/String', 'java/lang/String', 'java/lang/String', 'org/elasticsearch/common/settings/Settings', 'org/elasticsearch/client/transport/TransportClient', long, long\_2nd }  
stack: { 'org/elasticsearch/action/search/SearchRequestBuilder', 'org/elasticsearch/search/aggregations/bucket/terms/TermsAggregationBuilder' }  
Bytecode:  
0x0000000: 1100 0957 2ab8 0463 b900 8a01 003a 042a  
0x0000010: b804 63b9 008d 0100 3a05 2ab8 0463 b900  
0x0000020: 9001 003a 06b8 0093 1299 1905 b600 9bb6  
0x0000030: 00a1 3a07 013a 08bb 00a5 5919 0703 bd00  
0x0000040: a7b7 00a9 bb00 ac59 b800 ae11 2454 b700  
0x0000050: b4b6 00b7 3a08 b800 bb37 0919 0804 bd00  
0x0000060: 8859 0319 0653 b900 c102 002c b600 c704  
0x0000070: bd00 8859 032d 53b6 00cd 03b6 00d0 03b6  
0x0000080: 00d4 12d7 b800 d912 dfb6 00e1 b804 67b8  
0x0000090: 046d c000 e203 b600 e7b6 00eb b600 efb9  
0x00000a0: 00f3 0100 b804 70b8 046d c000 f93a 0bb8  
0x00000b0: 00bb 370c b200 22bb 00fb 5912 fdb7 00ff  
0x00000c0: 2db6 0102 1301 06b6 0102 160c 1609 65b6  
0x00000d0: 0108 b601 0bb9 010e 0200 b800 bb37 092a  
0x00000e0: 2b19 0bb6 0114 b800 bb37 0cb2 0022 bb00  
0x00000f0: fb59 12fd b700 ff2d b601 0213 0118 b601  
0x0000100: 0216 0c16 0965 b601 08b6 010b b901 0e02  
0x0000110: 00a7 003c 3a09 b200 2219 09b6 011a 1909  
0x0000120: b901 1f03 00bb 0040 5913 0123 b701 25b8  
0x0000130: 0476 c001 37bf 3a0e 1908 c600 0a19 08b9  
0x0000140: 0126 0100 190e b804 76c0 0137 bf19 08c6  
0x0000150: 000a 1908 b901 2601 00b1  
Exception Handler Table:  
bci [55, 273] =\> handler: 276  
bci [55, 310] =\> handler: 310  
Stackmap Table:  
full\_frame(@276,{Object[#1],Object[#134],Object[#132],Object[#136],Object[#136],Object[#136],Object[#136],Object[#148],Object[#194]},{Object[#283]})  
same\_locals\_1\_stack\_item\_frame(@310,Object[#311])  
full\_frame(@324,{Object[#1],Object[#134],Object[#132],Object[#136],Object[#136],Object[#136],Object[#136],Object[#148],Object[#194],Top,Top,Top,Top,Top,Object[#311]},{})  
full\_frame(@333,{Object[#1],Object[#134],Object[#132],Object[#136],Object[#136],Object[#136],Object[#136],Object[#148],Object[#194]},{})  
same\_frame(@345)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 29, 2018, 10:19pm UTC](https://discuss.elastic.co/t/upgrading-from-2-x-to-5-3-0-aggregation-errors/150622/2 "2018-10-29T22:19:15Z")

</div>

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