# Alternatives or making search filtering more efficient

**URL:** <https://discuss.elastic.co/t/alternatives-or-making-search-filtering-more-efficient/382796>\
**Category:** Elasticsearch\
**Created:** [October 17, 2025, 12:13am UTC](https://discuss.elastic.co/t/alternatives-or-making-search-filtering-more-efficient/382796 "2025-10-17T00:13:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![daveoap](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@daveoap](https://discuss.elastic.co/u/daveoap)\
**Post date:** [October 17, 2025, 12:13am UTC](https://discuss.elastic.co/t/alternatives-or-making-search-filtering-more-efficient/382796/1 "2025-10-17T00:13:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![john-wagster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/john-wagster/32/139021_2.png) [@john-wagster](https://discuss.elastic.co/u/john-wagster)\
**Post date:** [October 17, 2025, 1:44am UTC](https://discuss.elastic.co/t/alternatives-or-making-search-filtering-more-efficient/382796/2 "2025-10-17T01:44:10Z")

</div>

Welcome!

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