# Return date fields as long numbers when using synthetic \_source and having format of date as epoch\_millis

**URL:** <https://discuss.elastic.co/t/return-date-fields-as-long-numbers-when-using-synthetic-source-and-having-format-of-date-as-epoch-millis/369383>\
**Category:** Elasticsearch\
**Tags:** synthetic-source\
**Created:** [October 24, 2024, 6:57pm UTC](https://discuss.elastic.co/t/return-date-fields-as-long-numbers-when-using-synthetic-source-and-having-format-of-date-as-epoch-millis/369383 "2024-10-24T18:57:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbenesj](https://avatars.discourse-cdn.com/v4/letter/d/96bed5/32.png) [@dbenesj](https://discuss.elastic.co/u/dbenesj)\
**Post date:** [October 24, 2024, 6:57pm UTC](https://discuss.elastic.co/t/return-date-fields-as-long-numbers-when-using-synthetic-source-and-having-format-of-date-as-epoch-millis/369383/1 "2024-10-24T18:57:11Z")

</div>

We are using synthetic `_source` and `date` fields with format defined as `epoch_millis`. Our expectation would be to get such fields as long number but we get them as strings.  
As we understand it might be necessary when dates are being stored in most other formats, in this one it is odd.

Currently we got following from the search API:

```auto
{
  ...
  "hits" : {
    ...
    "hits" : [
      {
        ...
        "_source" : {
          "_created" : "1608193593998",
          ...
        }
      },
      ...
    ]
  }
}

```

for mapping:

```auto
{
  "index_name" : {
    "mappings" : {
      "_source" : {
        "mode" : "synthetic"
      },
      "properties" : {
        "_created" : {
          "type" : "date",
          "format" : "epoch_millis"
        },
        ...
      }
    }
  }
}

```

Is there a way to configure mapping the way that we get our `date` fields in `epoch_millis` format as `long` numbers even with `synthetic` `_source` please?

Expected search API output:

```auto
{
  ...
  "hits" : {
    ...
    "hits" : [
      {
        ...
        "_source" : {
          "_created" : 1608193593998,
          ...
        }
      },
      ...
    ]
  }
}

```
