I have a similar use-case as in https://github.com/elastic/elasticsearch/issues/10767
- price calculation data is stored in a children index (I know that this makes things more complex)
- one of the aggregations is based on price e.g. multiple price ranges
50 <= price < 100,
100 <= price < 150etc
- sorting can use such price
- post_filter can filter on such price
- a top hits aggregation of the price children objects is always needed, and it uses such price calculation; although I am doing this through a separate regular ES query at the moment, I plan to use top hits aggregation in a single query as explained here
The price calculation has a dependency on user request parameters, hence I use scripts (Lucene expressions).
Since there is no script result caching (as far as I understood), I am trying to re-engineer this around usage of function score. A few questions:
- can you foresee a better way to accomplish this?
- can function score be cached for re-use across queries?
- do I need to copy the post_filter as a filter in the top hits aggregation? (to avoid calculating top hits for results that will be skipped)