# Changes to template based queries

**URL:** https://discuss.elastic.co/t/changes-to-template-based-queries/52679
**Category:** Elasticsearch
**Created:** [June 14, 2016, 2:02am UTC](https://discuss.elastic.co/t/changes-to-template-based-queries/52679 "2016-06-14T02:02:14Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![John\_D\_Ament](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/john_d_ament/32/764_2.png) [@John\_D\_Ament](https://discuss.elastic.co/u/John_D_Ament)
#### Post date: [June 14, 2016, 2:02am UTC](https://discuss.elastic.co/t/changes-to-template-based-queries/52679/1 "2016-06-14T02:02:14Z")

</div>

Hi, I'm trying to upgrade from ES 1.7.3 to 2.3.3. I'm mostly done, however I've run into some issues trying to convert one of my templated queries to work in 2.3.3. This is the query, only changes are to obscure some attributes.

```
{
  "_source": [
    "record.openedDate",
    "record.typeName",
    "record.fields.Title",
    "record.canceled"
  ],
  "sort": [
    "record.typeName",
    "record.openedDate"
  ],
  "size" : 1000,
  "query": {
    "filtered": {
      "query": {
        "match_all": {}
      },
      "filter": {
        "and": {
          "filters": [
            {
              "range": {
                "record.openedDate": {
                  "from": "{{from}}"
                }
              }
            },
            {
              "bool": {
                "must": {
                  "term": {
                    "record.canceled": "false"
                  }
                }
              }
            }
          ]
        }
      }
    }
  },
  "aggs": {
    "openedMonth": {
      "date_histogram": {
        "field": "record.openedDate",
        "interval": "month"
      },
      "aggs": {
        "byType": {
          "terms": {
            "field": "_type"
          }
        }
      }
    }
  }
}

```

I get quite a few errors. ES complains that \_source, sort, size and aggs shouldn't be there. If they shouldn't be here, where do they go?

---

<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 5, 2017, 10:44pm UTC](https://discuss.elastic.co/t/changes-to-template-based-queries/52679/2 "2017-07-05T22:44:09Z")

</div>


