# Elastic Query Type Casting Error

**URL:** <https://discuss.elastic.co/t/elastic-query-type-casting-error/208587>\
**Category:** Elasticsearch\
**Created:** [November 19, 2019, 9:13pm UTC](https://discuss.elastic.co/t/elastic-query-type-casting-error/208587 "2019-11-19T21:13:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![akrauss](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@akrauss](https://discuss.elastic.co/u/akrauss)\
**Post date:** [November 19, 2019, 9:13pm UTC](https://discuss.elastic.co/t/elastic-query-type-casting-error/208587/1 "2019-11-19T21:13:02Z")

</div>

I have this index which all the mappings are long type.

 ![imgpsh_mobile_save](https://us1.discourse-cdn.com/elastic/original/3X/1/0/10831c6447b0444bfa9eb770449ba10d209d13ab.jpeg)

I have a query with a structure works with all my other indices:

```
GET dqs_profgen_*/_search
{
  "query": {
    "bool": {
      "filter": {
        "range": {
          "time_bkt": {
            "from": "now-100d",
            "to": "now"
          }
        }
      }
    }
  },
  "aggs": {
    "network": {
      "composite": {
        "sources": [
          {
            "date": {
              "date_histogram": {
                "field": "time_bkt",
                "interval": "1d"
              }
            }
          },
          {
            "attr1": {
              "terms": {
                "field": "company_id"
              }
            }
          },
          {
            "attr2": {
              "terms": {
                "field": "mkfile_id"
              }
            }
          }
        ],
        "size": 10000
      },
      "aggs": {
        "metric": {
          "sum": {
            "field": "unchanged_profiles"
          }
        }
      }
    }
  }
}

```

Despite that all the fields are mapped to type long, I get this error

 ![c1d5f2f1-1172-4d43-a48d-71b97f46c068](https://us1.discourse-cdn.com/elastic/original/3X/7/0/70c4797eb97fadd08683381896b059bfcd153c14.jpeg)

How can I address this error? Do I need to modify my query to map a type?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [November 21, 2019, 9:08am UTC](https://discuss.elastic.co/t/elastic-query-type-casting-error/208587/2 "2019-11-21T09:08:33Z")

</div>

please stop sharing screenshots but share real code/JSON snippets. Screenshots are super hard to read.

Can you also share the full mapping?

Last but not least please enable the full stack trace by adding `error_trace=true` to your request and then put that response here as well (or alternatively in a gist/pastebin and link it).

Thanks!

---

<div class="post-metadata">

**Author:** ![akrauss](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@akrauss](https://discuss.elastic.co/u/akrauss)\
**Post date:** [November 21, 2019, 3:40pm UTC](https://discuss.elastic.co/t/elastic-query-type-casting-error/208587/3 "2019-11-21T15:40:00Z")

</div>

Hey Alexander,

I solved this problem on my own yesterday and forgot to remove the post- thank you

---

<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:** [December 19, 2019, 3:40pm UTC](https://discuss.elastic.co/t/elastic-query-type-casting-error/208587/4 "2019-12-19T15:40:02Z")

</div>

Closed on December 19, 2019, 3:40pm UTC

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