Collapse after rescore

Hello everyone
I know that in ver. 5.3 (?) it would be possible to run collapse with rescore and it was reverted, but the cases that I have, forcing me to develop this functionality. The main idea is to create a plugin with this behavior.
I studied ElasticSearch source codes and this is what I have at the moment:

  • has a strict execution order in execute method and rescore phase is executed after all collectors (in private static boolean execute) and before the second phase of aggregation aggregationPhase.execute(searchContext) is executed; Looks like the only way with plugin is to use AggregationSpec
  • so, all i need is to create class that inherited from InternalAggregations to implement the reduce method in which i should (?) do Collapsing by id of the item sorted by score

My question is whether there are other ways to implement functionality like that (I don’t want to change the elastic code, at least for now). If not, how can you pull the score from during the aggregation (I understand that it is possible through nested aggregation with scripting that does not look so good)

My setup is elastic ver. 6.6

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