# Regexp vs Include performance comparison

**URL:** <https://discuss.elastic.co/t/regexp-vs-include-performance-comparison/123730>\
**Category:** Elasticsearch\
**Created:** [March 13, 2018, 1:06pm UTC](https://discuss.elastic.co/t/regexp-vs-include-performance-comparison/123730 "2018-03-13T13:06:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cekeriya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cekeriya/32/27594_2.png) [@cekeriya](https://discuss.elastic.co/u/cekeriya)\
**Post date:** [March 13, 2018, 1:06pm UTC](https://discuss.elastic.co/t/regexp-vs-include-performance-comparison/123730/1 "2018-03-13T13:06:13Z")

</div>

Hi everybody

I work on a project and I need to aggregate the results based on "created" and "labels" field.  
I created following queries that both give the result as I expected. But I want to learn that which query runs more fast?

My first query:

```
{
  "size": 0,
  "aggs": {
    "HEATMAP": {
      "date_histogram": {
        "field": "created",
        "interval": "day"
      },
      "aggs": {
        "BEHAVIOUR_CHANGE": {
          "terms": {
            "field": "labels",
            "include": "behavior-change"
          }
        },
        "FIRST_OCCURRENCE": {
          "terms": {
            "field": "labels",
            "include": "first-occurrence"
          }
        }
      }
    }
  }
}

```

My second query:

```
{
  "size": 0,
  "aggs": {
    "HEATMAP": {
      "date_histogram": {
        "field": "created",
        "interval": "day"
      },
      "aggs": {
        "BEHAVIOUR_CHANGE": {
          "filter": {
            "regexp": {
              "labels": "behavior-change"
            }
          }
        },
        "FIRST_OCCURRENCE": {
          "filter": {
            "regexp": {
              "labels": "first-occurrence"
            }
          }
        }
      }
    }
  }
}
```

---

<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:** [April 10, 2018, 1:06pm UTC](https://discuss.elastic.co/t/regexp-vs-include-performance-comparison/123730/2 "2018-04-10T13:06:28Z")

</div>

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