# Mapping definition help (copy\_to, dates)

**URL:** <https://discuss.elastic.co/t/mapping-definition-help-copy-to-dates/20804>\
**Category:** Elasticsearch\
**Created:** [November 18, 2014, 4:40am UTC](https://discuss.elastic.co/t/mapping-definition-help-copy-to-dates/20804 "2014-11-18T04:40:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff\_Fogarty](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeff_fogarty/32/46751_2.png) [@Jeff\_Fogarty](https://discuss.elastic.co/u/Jeff_Fogarty)\
**Post date:** [November 18, 2014, 4:40am UTC](https://discuss.elastic.co/t/mapping-definition-help-copy-to-dates/20804/1 "2014-11-18T04:40:23Z")

</div>

I'm looking to analyze network utilization data supplied by our vendor.  
One challenge is the observed data and time are in separate fields.

I like to combine the fields date\_observed and cst\_observed into a  
date/time field. Is this possible?

Below defines that mapping I've come up with, I get a few errors with the  
below

No handler for type [timestamp] declared on fields

my\_ts

cst\_observed

{ "mappings": {  
"utilization": {  
"dynamic": "false", "properties": {  
"cst\_observed": {"type": "timestamp", "copy\_to": "my\_ts"}  
,"date\_observed": {"type": "date", "copy\_to": "my\_ts"}  
,"inbound\_mbps": {"type": "float"}  
,"inbound\_percent": {"type": "float"}  
,"ip\_addr": {"type": "ip"}  
,"outbound\_mbps": {"type": "float"}  
,"outbound\_percent": {"type": "float"}  
,"provider": {"type": "string"}  
,"reporting\_begin": {"type": "date"}  
,"reporting\_end": {"type": "date"}  
,"speed": {"type": "float"}  
,"my\_ts":{"type": "timestamp", "format": "HH:mm:ss  
mm/dd/yyyy"}  
}  
}  
}  
}'

Thanks,

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/0109138a-4f04-4f66-9ab5-2f7f85fc9a77%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0109138a-4f04-4f66-9ab5-2f7f85fc9a77%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![johtani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johtani/32/44956_2.png) [@johtani](https://discuss.elastic.co/u/johtani)\
**Post date:** [December 6, 2014, 3:04pm UTC](https://discuss.elastic.co/t/mapping-definition-help-copy-to-dates/20804/2 "2014-12-06T15:04:48Z")

</div>

Hi Jeff,

elasticsearch doesn’t have “timestamp” type. elasticsearch have only date type.

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

And you should use “transform” instead of “copy\_to”.

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Example mapping using transform:  
{  
"mappings": {  
"utilization": {  
"dynamic": "false",

```
    "transform" : {
        "script" : "if (!ctx._source['cst_observed'].empty && !ctx._source['date_observed'].empty) ctx._source['my_ts'] = ctx._source['cst_observed'] + ' '+ ctx._source['date_observed']",
        "lang": "groovy"
    },
        "properties": {
            "cst_observed": {"type": "string"}
            ,"date_observed": {"type": "string"}
            ,"inbound_mbps": {"type": "float"}
            ,"inbound_percent": {"type": "float"}
            ,"ip_addr": {"type": "ip"}
            ,"outbound_mbps": {"type": "float"}
            ,"outbound_percent": {"type": "float"}
            ,"provider": {"type": "string"}
            ,"reporting_begin": {"type": "date"}
            ,"reporting_end": {"type": "date"}
            ,"speed": {"type": "float"}
            ,"my_ts":{"type": "date", "format": "HH:mm:ss mm/dd/yyyy"}
  }
}

```

}  
}

That is only example.  
I hope that those help you out.

* * *

Jun Ohtani  
[johtani@gmail.com](mailto:johtani@gmail.com)  
blog : [http://blog.johtani.info](http://blog.johtani.info)  
twitter : [http://twitter.com/johtani](http://twitter.com/johtani)

> 2014/11/18 13:40、Jeff Fogarty [j.007ba7@gmail.com](mailto:j.007ba7@gmail.com) のメール：
> 
> I'm looking to analyze network utilization data supplied by our vendor. One challenge is the observed data and time are in separate fields.
> 
> I like to combine the fields date\_observed and cst\_observed into a date/time field. Is this possible?
> 
> Below defines that mapping I've come up with, I get a few errors with the below
> 
> No handler for type [timestamp] declared on fields  
> my\_ts  
> cst\_observed
> 
> { "mappings": {  
> "utilization": {  
> "dynamic": "false", "properties": {  
> "cst\_observed": {"type": "timestamp", "copy\_to": "my\_ts"}  
> ,"date\_observed": {"type": "date", "copy\_to": "my\_ts"}  
> ,"inbound\_mbps": {"type": "float"}  
> ,"inbound\_percent": {"type": "float"}  
> ,"ip\_addr": {"type": "ip"}  
> ,"outbound\_mbps": {"type": "float"}  
> ,"outbound\_percent": {"type": "float"}  
> ,"provider": {"type": "string"}  
> ,"reporting\_begin": {"type": "date"}  
> ,"reporting\_end": {"type": "date"}  
> ,"speed": {"type": "float"}  
> ,"my\_ts":{"type": "timestamp", "format": "HH:mm:ss mm/dd/yyyy"}  
> }  
> }  
> }  
> }'
> 
> Thanks,
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/0109138a-4f04-4f66-9ab5-2f7f85fc9a77%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0109138a-4f04-4f66-9ab5-2f7f85fc9a77%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/B58F56BA-643C-4B75-98E3-35DB5282FE73%40gmail.com](https://groups.google.com/d/msgid/elasticsearch/B58F56BA-643C-4B75-98E3-35DB5282FE73%40gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 6, 2014, 3:24pm UTC](https://discuss.elastic.co/t/mapping-definition-help-copy-to-dates/20804/3 "2014-12-06T15:24:18Z")

</div>

Our you can always transform in you client application. The advantage of  
transform is that it is done _post_ source like copy\_to. Meaning is you  
like the original format for disk space and highlighting purposes you  
should use transform. If you don't, transform in your app.

Nik

On Sat, Dec 6, 2014 at 10:04 AM, Jun Ohtani [johtani@gmail.com](mailto:johtani@gmail.com) wrote:

> Hi Jeff,
> 
> elasticsearch doesn’t have “timestamp” type. elasticsearch have only date  
> type.
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html#date)
> 
> And you should use “transform” instead of “copy\_to”.
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-transform.html)
> 
> Example mapping using transform:  
> {  
> "mappings": {  
> "utilization": {  
> "dynamic": "false",
> 
> ```
> "transform" : {
> "script" : "if (!ctx._source['cst_observed'].empty &&
> 
> ```
> 
> !ctx.\_source['date\_observed'].empty) ctx.\_source['my\_ts'] =  
> ctx.\_source['cst\_observed'] + ' '+ ctx.\_source['date\_observed']",  
> "lang": "groovy"  
> },  
> "properties": {  
> "cst\_observed": {"type": "string"}  
> ,"date\_observed": {"type": "string"}  
> ,"inbound\_mbps": {"type": "float"}  
> ,"inbound\_percent": {"type": "float"}  
> ,"ip\_addr": {"type": "ip"}  
> ,"outbound\_mbps": {"type": "float"}  
> ,"outbound\_percent": {"type": "float"}  
> ,"provider": {"type": "string"}  
> ,"reporting\_begin": {"type": "date"}  
> ,"reporting\_end": {"type": "date"}  
> ,"speed": {"type": "float"}  
> ,"my\_ts":{"type": "date", "format": "HH:mm:ss mm/dd/yyyy"}  
> }  
> }  
> }  
> }
> 
> That is only example.  
> I hope that those help you out.
> 
> * * *
> 
> Jun Ohtani  
> [johtani@gmail.com](mailto:johtani@gmail.com)  
> blog : [http://blog.johtani.info](http://blog.johtani.info)  
> twitter : [http://twitter.com/johtani](http://twitter.com/johtani)
> 
> > 2014/11/18 13:40、Jeff Fogarty [j.007ba7@gmail.com](mailto:j.007ba7@gmail.com) のメール：
> > 
> > I'm looking to analyze network utilization data supplied by our vendor.  
> > One challenge is the observed data and time are in separate fields.
> > 
> > I like to combine the fields date\_observed and cst\_observed into a  
> > date/time field. Is this possible?
> > 
> > Below defines that mapping I've come up with, I get a few errors with  
> > the below
> > 
> > No handler for type [timestamp] declared on fields  
> > my\_ts  
> > cst\_observed
> > 
> > { "mappings": {  
> > "utilization": {  
> > "dynamic": "false", "properties": {  
> > "cst\_observed": {"type": "timestamp", "copy\_to": "my\_ts"}  
> > ,"date\_observed": {"type": "date", "copy\_to": "my\_ts"}  
> > ,"inbound\_mbps": {"type": "float"}  
> > ,"inbound\_percent": {"type": "float"}  
> > ,"ip\_addr": {"type": "ip"}  
> > ,"outbound\_mbps": {"type": "float"}  
> > ,"outbound\_percent": {"type": "float"}  
> > ,"provider": {"type": "string"}  
> > ,"reporting\_begin": {"type": "date"}  
> > ,"reporting\_end": {"type": "date"}  
> > ,"speed": {"type": "float"}  
> > ,"my\_ts":{"type": "timestamp", "format": "HH:mm:ss  
> > mm/dd/yyyy"}  
> > }  
> > }  
> > }  
> > }'
> > 
> > Thanks,
> > 
> > --  
> > You received this message because you are subscribed to the Google  
> > Groups "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send  
> > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/0109138a-4f04-4f66-9ab5-2f7f85fc9a77%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0109138a-4f04-4f66-9ab5-2f7f85fc9a77%40googlegroups.com)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/B58F56BA-643C-4B75-98E3-35DB5282FE73%40gmail.com](https://groups.google.com/d/msgid/elasticsearch/B58F56BA-643C-4B75-98E3-35DB5282FE73%40gmail.com)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2AY%2BKGoKxBFPSsayrGJ12VhLekFctmAvdCZo5SB95SdA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2AY%2BKGoKxBFPSsayrGJ12VhLekFctmAvdCZo5SB95SdA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:45am UTC](https://discuss.elastic.co/t/mapping-definition-help-copy-to-dates/20804/4 "2017-07-06T00:45:19Z")

</div>


