# Aggregations Migration ES7 to ES8.11.1

**URL:** <https://discuss.elastic.co/t/aggregations-migration-es7-to-es8-11-1/349255>\
**Category:** Elasticsearch\
**Created:** [December 13, 2023, 12:03pm UTC](https://discuss.elastic.co/t/aggregations-migration-es7-to-es8-11-1/349255 "2023-12-13T12:03:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dev1234](https://avatars.discourse-cdn.com/v4/letter/d/d78d45/32.png) [@Dev1234](https://discuss.elastic.co/u/Dev1234)\
**Post date:** [December 13, 2023, 12:03pm UTC](https://discuss.elastic.co/t/aggregations-migration-es7-to-es8-11-1/349255/1 "2023-12-13T12:03:42Z")

</div>

Hello dear community,

I am currently migrating our ES7 to ES8 and am now encountering the problem that I cannot find a solution as to how I can migrate SearchHits or the **.get(String)** method.

```auto
public static Set<Integer> getAggregations(SearchHits<ElasticSearchArticleDto> search, String aggregation) {
    Set<Integer> result = new LinkedHashSet<>();
    
    if (search.getAggregations() != null && (search.getAggregations()).get(aggregation) != null) {
        ((ParsedLongTerms) (search.getAggregations()).get(aggregation)).getBuckets().forEach(bucket -> result.add(bucket.getKeyAsNumber().intValue()));
    }

    return result;
}

```

I am now using org.springframework.data:spring-data-elasticsearch:5.1.5 with the migration to ES8

Would be very grateful for any help on how I can change this method so that it works with ES8.

---

<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:** [January 10, 2024, 12:03pm UTC](https://discuss.elastic.co/t/aggregations-migration-es7-to-es8-11-1/349255/2 "2024-01-10T12:03:56Z")

</div>

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