# Very Slow query on ElasticSearch

**URL:** <https://discuss.elastic.co/t/very-slow-query-on-elasticsearch/143307>\
**Category:** Elasticsearch\
**Created:** [August 7, 2018, 11:18am UTC](https://discuss.elastic.co/t/very-slow-query-on-elasticsearch/143307 "2018-08-07T11:18:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![magorbe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magorbe/32/36871_2.png) [@magorbe](https://discuss.elastic.co/u/magorbe)\
**Post date:** [August 7, 2018, 11:18am UTC](https://discuss.elastic.co/t/very-slow-query-on-elasticsearch/143307/1 "2018-08-07T11:18:38Z")

</div>

I have the next Elastic query :

```
{
  "_source": {"includes": ["sample.id*"]},
  "query": {
    "filtered": {
      "query": { "match_all": {} },
      "filter": {
        "nested": {
          "path": "sample.covered_region",
          "query": {
            "filtered": {
               "query": {
                    "term": {"sample.covered_region.chr": "chr10"}
               },
               "filter": {
                   "bool": {
                       "must": [
                        {
                          "range": {
                            "sample.covered_region.start": {
                              "lte": "87713311"
                            }
                          }
                        },
                        {
                          "range": {
                            "sample.covered_region.end": {
                              "gte": "87713311"
                            }
                          }
                        }
                        ]
                   }
               }
            }
          }
        }
      }
    }
  }
}

```

but runs very very very slow... (8 seconds!)

Anybody knows a more efficient way to search? Thanks!!!

If I do the same query only with one range I have very good time result (300 ms)

```
{
  "_source": {"includes": ["sample.id*"]},
  "query": {
    "filtered": {
      "query": { "match_all": {} },
      "filter": {
        "nested": {
          "path": "sample.covered_region",
          "query": {
            "filtered": {
               "query": {
                    "term": {"sample.covered_region.chr": "chr10"}
               },
               "filter": {
                   "bool": {
                       "must": [
                        {
                          "range": {
                            "sample.covered_region.start": {
                              "lte": "87713311"
                            }
                          }
                        }
                        ]
                   }
               }
            }
          }
        }
      }
    }
  }
}

```

whats wrong here??

---

<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:** [September 4, 2018, 11:18am UTC](https://discuss.elastic.co/t/very-slow-query-on-elasticsearch/143307/2 "2018-09-04T11:18:44Z")

</div>

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