I am trying to build ecommerce search engine with facets using Elasticsearch. I am using Elasticsearch-ltr plugin, which provides me possibility to rescore documents using machine learning formula. I want to cut off tail of non relevant documents (which are documents with low score) before applying my aggregations. Since this score is ML generated, it is meaningful and could be used to cut documents with some score threshold.
If I will calculate aggregation on all matched documents, I will possibly get irrelevant aggregation buckets. For example I can get brand [XXX] for query [smartphone YYY].
What I found is Elasticsearch applies all aggregations before rescoring documents. I tried sampler and range aggregations. I also tried to calculate min / max score per bucket with script aggregator. Every time I get score from main query, not from rescore. Also didn't find anything about this in documentation.
Maybe I can somehow apply aggregations on top scored documents using score from rescore phase?
Thank you in advance