# Slow bool query

**URL:** <https://discuss.elastic.co/t/slow-bool-query/127027>\
**Category:** Elasticsearch\
**Created:** [April 6, 2018, 6:16am UTC](https://discuss.elastic.co/t/slow-bool-query/127027 "2018-04-06T06:16:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BS1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bs1/32/1718_2.png) [@BS1](https://discuss.elastic.co/u/BS1)\
**Post date:** [April 6, 2018, 6:16am UTC](https://discuss.elastic.co/t/slow-bool-query/127027/1 "2018-04-06T06:16:51Z")

</div>

The following request takes at least 500ms every time we execute it. This is on a an index with 5 primary shards of 1.2GB each. Is there anything in the query that would explain the slowness ? The cluster is otherwise performant. We're still running ES 2.4.1.

```
{
  "query": {
    "filtered": {
      "filter": {
        "bool": {
          "must": [
            {
              "has_parent": {
                "type": "article",
                "filter": {
                  "bool": {
                    "must": [
                      {
                        "term": {
                          "account_id": 67316
                        }
                      },
                      {
                        "term": {
                          "brand_id": 3600001925
                        }
                      },
                      {
                        "terms": {
                          "section_id": [
                            200923332,
                            3600117465
                          ]
                        }
                      }
                    ],
                    "must_not": []
                  }
                }
              }
            },
            {
              "term": {
                "is_active": true
              }
            },
            {
              "terms": {
                "status": [
                  "draft",
                  "published"
                ]
              }
            },
            {
              "terms": {
                "is_source": [
                  true
                ]
              }
            }
          ],
          "must_not": []
        }
      },
      "query": {
        "multi_match": {
          "fields": [
            "body*^1.5",
            "title*^2"
          ],
          "query": "",
          "type": "phrase_prefix",
          "zero_terms_query": "all"
        }
      }
    }
  },
  "sort": {
    "updated.timestamp": {
      "nested_path": "updated",
      "order": "desc"
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 6, 2018, 6:36am UTC](https://discuss.elastic.co/t/slow-bool-query/127027/2 "2018-04-06T06:36:44Z")

</div>

Parent/Child + Nested fields (sort) are most likely the ones I'd think about.

---

<div class="post-metadata">

**Author:** ![Sravanthi\_N\_S\_CH](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sravanthi_n_s_ch/32/50473_2.png) [@Sravanthi\_N\_S\_CH](https://discuss.elastic.co/u/Sravanthi_N_S_CH)\
**Post date:** [April 6, 2018, 7:30am UTC](https://discuss.elastic.co/t/slow-bool-query/127027/3 "2018-04-06T07:30:31Z")

</div>

I remember seeing similar problem with the project that I am working on.  
Initially, we were using parent-child documents where the search response times are way higher. We migrated to nested structure and noticed considerable change in the search response times.

---

<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:** [May 4, 2018, 7:30am UTC](https://discuss.elastic.co/t/slow-bool-query/127027/4 "2018-05-04T07:30:37Z")

</div>

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