Hello everyone
I know that in ver. 5.3 (?) it would be possible to run collapse with rescore https://github.com/elastic/elasticsearch/pull/28521 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:
- QueryPhase.java has a strict execution order in
execute
method and rescore phase is executed after all collectors (inprivate static boolean execute
) and before the second phase of aggregationaggregationPhase.execute(searchContext)
is executed; Looks like the only way with plugin is to useAggregationSpec
- so, all i need is to create class that inherited from
InternalAggregations
to implement thereduce
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
Thanks!