Alternatives or making search filtering more efficient

Hi,

I have a query which uses function score and filters to modify the weight of the results so i can order the results based on which filter the doc matches. The issue is that in these filters i need to use a terms_set query against sometimes a large array of ids. this terms_set query is run in 6 separate filters, so when the id list is large it makes the query really intensive and slow and some times we receive a memory error from elasticsearch. I’m wondering if there is an alternative to our current approach which is more efficient. Thanks for your help.

Welcome!

Can you share your query and your mapping as well? Would be a bit easier to reason through potentially better search queries.