# How to get score aggregations on the scores after rescore phase?

**URL:** <https://discuss.elastic.co/t/how-to-get-score-aggregations-on-the-scores-after-rescore-phase/286984>\
**Category:** Elasticsearch\
**Created:** [October 18, 2021, 11:32am UTC](https://discuss.elastic.co/t/how-to-get-score-aggregations-on-the-scores-after-rescore-phase/286984 "2021-10-18T11:32:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Igor\_L](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_l/32/79803_2.png) [@Igor\_L](https://discuss.elastic.co/u/Igor_L)\
**Post date:** [October 18, 2021, 11:32am UTC](https://discuss.elastic.co/t/how-to-get-score-aggregations-on-the-scores-after-rescore-phase/286984/1 "2021-10-18T11:32:53Z")

</div>

org/Elasticsearch/search/query/QueryPhase.java:

```auto
// Pre-process aggregations as late as possible. In the case of a DFS_Q_T_F
// request, preProcess is called on the DFS phase phase, this is why we pre-process them
// here to make sure it happens during the QUERY phase
aggregationPhase.preProcess(searchContext);
boolean rescore = executeInternal(searchContext);

if (rescore) { // only if we do a regular search
     rescorePhase.execute(searchContext);
}
suggestPhase.execute(searchContext);
aggregationPhase.execute(searchContext);

if (searchContext.getProfilers() != null) {
       ProfileShardResult shardResults = SearchProfileShardResults
            .buildShardResults(searchContext.getProfilers());
       searchContext.queryResult().profileResults(shardResults);
   }

```

As I can see aggregations work only with scores from DFS phase.  
Is there any way/could you propose any workaround to run score aggregations on the scores after `rescorePhase`?

---

<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:** [November 15, 2021, 11:33am UTC](https://discuss.elastic.co/t/how-to-get-score-aggregations-on-the-scores-after-rescore-phase/286984/2 "2021-11-15T11:33:49Z")

</div>

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