# Filter on thousands of IDS - How is it efficient?

**URL:** <https://discuss.elastic.co/t/filter-on-thousands-of-ids-how-is-it-efficient/9649>\
**Category:** Elasticsearch\
**Created:** [November 9, 2012, 2:49pm UTC](https://discuss.elastic.co/t/filter-on-thousands-of-ids-how-is-it-efficient/9649 "2012-11-09T14:49:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Loic\_Bertron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/loic_bertron/32/1794_2.png) [@Loic\_Bertron](https://discuss.elastic.co/u/Loic_Bertron)\
**Post date:** [November 9, 2012, 2:49pm UTC](https://discuss.elastic.co/t/filter-on-thousands-of-ids-how-is-it-efficient/9649/1 "2012-11-09T14:49:48Z")

</div>

Hello,

I have to restrict my result based on date, and multi conditions to  
analyse. I have about a billion documents since many years and these  
restrictions apply to only documents from last few days. In order to be  
efficient, to use the caching feature with ElasticSearch, i was thinking  
about using a third party tool to get all my documents restricted, and ask  
ElasticSearch to do not return these results. I would use such query :

"filtered" : {

```
    "query" : {

        "term" : { "body" : "Obama" }

    },

    "filter" : {

        "not" : {

            "ids" : {

                    "values" : ["1", "4", "100"]

            }

        }

```

Is it really worth it if i send an array of 1000 values ? 10000 values ?

Thanks a lot.

Loïc

--

---

<div class="post-metadata">

**Author:** ![Chris\_Male](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris_male/32/2607_2.png) [@Chris\_Male](https://discuss.elastic.co/u/Chris_Male)\
**Post date:** [November 10, 2012, 2:54am UTC](https://discuss.elastic.co/t/filter-on-thousands-of-ids-how-is-it-efficient/9649/2 "2012-11-10T02:54:25Z")

</div>

Hi,

On Saturday, November 10, 2012 3:49:48 AM UTC+13, Loïc Bertron wrote:

> Hello,
> 
> I have to restrict my result based on date, and multi conditions to  
> analyse. I have about a billion documents since many years and these  
> restrictions apply to only documents from last few days. In order to be  
> efficient, to use the caching feature with Elasticsearch, i was thinking  
> about using a third party tool to get all my documents restricted, and ask  
> Elasticsearch to do not return these results. I would use such query :
> 
> "filtered" : {
> 
> ```
> "query" : {
> 
> "term" : { "body" : "Obama" }
> 
> },
> 
> "filter" : {
> 
> "not" : {
> 
> "ids" : {
> 
> "values" : ["1", "4", "100"]
> 
> }
> 
> }
> 
> ```
> 
> Is it really worth it if i send an array of 1000 values ? 10000 values ?

What do you mean by 'is it really worth it'? Do you mean will it perform  
well? will it cache well?

> Thanks a lot.
> 
> Loïc

--

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:05am UTC](https://discuss.elastic.co/t/filter-on-thousands-of-ids-how-is-it-efficient/9649/3 "2017-07-06T03:05:00Z")

</div>


