# Elasticsearch exact filter term limits?

**URL:** <https://discuss.elastic.co/t/elasticsearch-exact-filter-term-limits/200278>\
**Category:** Elasticsearch\
**Created:** [September 19, 2019, 5:19pm UTC](https://discuss.elastic.co/t/elasticsearch-exact-filter-term-limits/200278 "2019-09-19T17:19:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wassim\_Ben\_Amor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wassim_ben_amor/32/39799_2.png) [@Wassim\_Ben\_Amor](https://discuss.elastic.co/u/Wassim_Ben_Amor)\
**Post date:** [September 19, 2019, 5:19pm UTC](https://discuss.elastic.co/t/elasticsearch-exact-filter-term-limits/200278/1 "2019-09-19T17:19:12Z")

</div>

Hello,  
I want to know what are the limits of exact filter terms.

If I have 2 millions of documents with simple data like indexed in one index with 5 shards and 1 replicas :  
{  
"attr1" : "hello",  
"attr2" : false,  
"attr3" : 1568913082520,  
"attr4" : true  
}  
when I launch this request which represents a an exact term filter :  
AND( OR(attr1=hello,attr2=false), x\<attr3\<y, OR(attr1=hello, attr4=true))

```
 "query": {
        "bool": {
            "filter": {
                "bool": {
                    "must": [
                        {
                            "bool": {
                                "should": [
                                    {
                                        "term": {
                                            "attr1": "hello"
                                        }
                                    },
                                    {
                                        "term": {
                                            "attr2": false
                                        }
                                    }
                                ]
                            }
                        },
                        {
                           "range": {
                              "attr3": {
                                  "gte": 1568239200000,
                                  "lte": 1568913151313
                              }
                          }
                        },
                        {
                            "bool": {
                                "should": [
                                    {
                                        "term": {
                                            "attr1": "hello"
                                        }
                                    },
                                    {
                                        "term": {
                                            "attr4": true
                                        }
                                    }
                                ]
                            }
                        }
                    ]
                }
            }
        }
    }

```

I want to know by filtering on data in this way, do I will get accurate count of documents when I set "track\_total\_hits" to true. And I want to know if it will match really all the documents  
Thank you !

---

<div class="post-metadata">

**Author:** ![Wassim\_Ben\_Amor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wassim_ben_amor/32/39799_2.png) [@Wassim\_Ben\_Amor](https://discuss.elastic.co/u/Wassim_Ben_Amor)\
**Post date:** [September 20, 2019, 8:40am UTC](https://discuss.elastic.co/t/elasticsearch-exact-filter-term-limits/200278/2 "2019-09-20T08:40:07Z")

</div>

Hello,  
Does anyone have an idea about this ? the "total" number is accurate ? Are all the documents respecting the filter rules are matched ?

Thank you,

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [September 20, 2019, 9:52am UTC](https://discuss.elastic.co/t/elasticsearch-exact-filter-term-limits/200278/3 "2019-09-20T09:52:09Z")

</div>

Prior to version 7, Elasticsearch would always return you an accurate number of hits. Since version 7.0, as a performance optimization, Elasticsearch will return an accurate number up to 10000 by default. If you want to always get an accurate number, you need to provide the [`track_total_hits`](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#request-body-search-track-total-hits) parameter, set to `true`.

---

<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:** [October 18, 2019, 9:52am UTC](https://discuss.elastic.co/t/elasticsearch-exact-filter-term-limits/200278/4 "2019-10-18T09:52:21Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
