# Cannot figure out how to add automatic timestamps when a document is indexed

**URL:** <https://discuss.elastic.co/t/cannot-figure-out-how-to-add-automatic-timestamps-when-a-document-is-indexed/21336>\
**Category:** Elasticsearch\
**Created:** [December 19, 2014, 8:08pm UTC](https://discuss.elastic.co/t/cannot-figure-out-how-to-add-automatic-timestamps-when-a-document-is-indexed/21336 "2014-12-19T20:08:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TealFawn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tealfawn/32/44845_2.png) [@TealFawn](https://discuss.elastic.co/u/TealFawn)\
**Post date:** [December 19, 2014, 8:08pm UTC](https://discuss.elastic.co/t/cannot-figure-out-how-to-add-automatic-timestamps-when-a-document-is-indexed/21336/1 "2014-12-19T20:08:45Z")

</div>

I've been trying a PUT to an existing index /solink\_health\_monitor/\_mapping  
to add a timestamp field to the document \_source

"mappings": {  
"stats": {  
"properties": {  
"@timestamp:": {  
"enabled": true,  
"store": true  
}  
}  
}  
}

I get the following response

{  
"error": "ActionRequestValidationException[Validation Failed: 1: mapping  
type is missing;]",  
"status": 400  
}

--  
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/2fe8afa3-31f7-427b-bc12-48f0c6d49694%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2fe8afa3-31f7-427b-bc12-48f0c6d49694%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Christian\_Hedegaard](https://avatars.discourse-cdn.com/v4/letter/c/ee7513/32.png) [@Christian\_Hedegaard](https://discuss.elastic.co/u/Christian_Hedegaard)\
**Post date:** [December 19, 2014, 8:18pm UTC](https://discuss.elastic.co/t/cannot-figure-out-how-to-add-automatic-timestamps-when-a-document-is-indexed/21336/2 "2014-12-19T20:18:31Z")

</div>

Try this:

{  
"template" : "whateverindex-\*",  
"mappings" : {  
"events" : {  
"\_timestamp" : { "enabled" : true },  
}  
}  
}

From: [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) [[mailto:elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)] On Behalf Of Jef Statham  
Sent: Friday, December 19, 2014 12:09 PM  
To: [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)  
Subject: Cannot figure out how to add automatic timestamps when a document is indexed.

I've been trying a PUT to an existing index /solink\_health\_monitor/\_mapping to add a timestamp field to the document \_source

"mappings": {  
"stats": {  
"properties": {  
"@timestamp:": {  
"enabled": true,  
"store": true  
}  
}  
}  
}

I get the following response

{  
"error": "ActionRequestValidationException[Validation Failed: 1: mapping type is missing;]",  
"status": 400  
}

--  
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)[mailto:elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2fe8afa3-31f7-427b-bc12-48f0c6d49694%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2fe8afa3-31f7-427b-bc12-48f0c6d49694%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/2fe8afa3-31f7-427b-bc12-48f0c6d49694%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/2fe8afa3-31f7-427b-bc12-48f0c6d49694%40googlegroups.com?utm_medium=email&utm_source=footer).  
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/5CF8216AA982AF47A8E6DEACA629D22B4EFF0743%40s-us-ex-6.US.R5S.com](https://groups.google.com/d/msgid/elasticsearch/5CF8216AA982AF47A8E6DEACA629D22B4EFF0743%40s-us-ex-6.US.R5S.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![TealFawn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tealfawn/32/44845_2.png) [@TealFawn](https://discuss.elastic.co/u/TealFawn)\
**Post date:** [December 19, 2014, 8:33pm UTC](https://discuss.elastic.co/t/cannot-figure-out-how-to-add-automatic-timestamps-when-a-document-is-indexed/21336/3 "2014-12-19T20:33:19Z")

</div>

Same error

"error": "ActionRequestValidationException[Validation Failed: 1: mapping  
type is missing;]",  
"status": 400

On Friday, 19 December 2014 15:18:46 UTC-5, Christian Hedegaard wrote:

> Try this:
> 
> {
> 
> "template" : "whateverindex-\*",
> 
> "mappings" : {
> 
> "events" : {
> 
> ```
> "_timestamp" : { "enabled" : true },
> 
> }
> 
> ```
> 
> }
> 
> }
> 
> _From:_ [elasti...@googlegroups.com](mailto:elasti...@googlegroups.com) \<javascript:\> [mailto:  
> [elasti...@googlegroups.com](mailto:elasti...@googlegroups.com) \<javascript:\>] \*On Behalf Of \*Jef Statham  
> _Sent:_ Friday, December 19, 2014 12:09 PM  
> _To:_ [elasti...@googlegroups.com](mailto:elasti...@googlegroups.com) \<javascript:\>  
> _Subject:_ Cannot figure out how to add automatic timestamps when a  
> document is indexed.
> 
> I've been trying a PUT to an existing index  
> /solink\_health\_monitor/\_mapping to add a timestamp field to the document  
> \_source
> 
> "mappings": {
> 
> ```
> "stats": {
> 
> "properties": {
> 
> "@timestamp:": {
> 
> "enabled": true,
> 
> "store": true
> 
> }
> 
> }
> 
> }
> 
> ```
> 
> }
> 
> I get the following response
> 
> {
> 
> ```
> "error": "ActionRequestValidationException[Validation Failed: 
> 
> ```
> 
> 1: mapping type is missing;]",
> 
> ```
> "status": 400
> 
> ```
> 
> }
> 
> --  
> 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/2fe8afa3-31f7-427b-bc12-48f0c6d49694%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2fe8afa3-31f7-427b-bc12-48f0c6d49694%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/2fe8afa3-31f7-427b-bc12-48f0c6d49694%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/2fe8afa3-31f7-427b-bc12-48f0c6d49694%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> 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/018967f3-6b08-4e09-a750-bd7339bd48a4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/018967f3-6b08-4e09-a750-bd7339bd48a4%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![TealFawn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tealfawn/32/44845_2.png) [@TealFawn](https://discuss.elastic.co/u/TealFawn)\
**Post date:** [December 19, 2014, 10:03pm UTC](https://discuss.elastic.co/t/cannot-figure-out-how-to-add-automatic-timestamps-when-a-document-is-indexed/21336/4 "2014-12-19T22:03:17Z")

</div>

Got the posting of the mapping figured out I think I was just missing some  
outter braces on my request body.

now enabling \_timestamp on the \_source of my document type still didn't  
enable automatic timestamps being added to the documents in Elasticsearch  
1.4.1.

My mapping now looks like:

{

- solink\_health\_monitor:  
{
  - mappings:  
{
    - stats:  
{
      - \_timestamp:  
{
        - enabled: true,
        - store: true  
},

      - properties:  
{
        - 
## numChanges: {

```
- type: "long"

```

},

      - tag:  
{
        - type: "string"  
}  
}  
}  
}

}  
}

On Friday, 19 December 2014 15:33:19 UTC-5, Jef Statham wrote:

> Same error
> 
> "error": "ActionRequestValidationException[Validation Failed: 1: mapping  
> type is missing;]",  
> "status": 400
> 
> On Friday, 19 December 2014 15:18:46 UTC-5, Christian Hedegaard wrote:
> 
> > Try this:
> > 
> > {
> > 
> > "template" : "whateverindex-\*",
> > 
> > "mappings" : {
> > 
> > "events" : {
> > 
> > ```
> > "_timestamp" : { "enabled" : true },
> > 
> > }
> > 
> > ```
> > 
> > }
> > 
> > }
> > 
> > _From:_ [elasti...@googlegroups.com](mailto:elasti...@googlegroups.com) [[mailto:elasti...@googlegroups.com](mailto:elasti...@googlegroups.com)] \*On  
> > Behalf Of \*Jef Statham  
> > _Sent:_ Friday, December 19, 2014 12:09 PM  
> > _To:_ [elasti...@googlegroups.com](mailto:elasti...@googlegroups.com)  
> > _Subject:_ Cannot figure out how to add automatic timestamps when a  
> > document is indexed.
> > 
> > I've been trying a PUT to an existing index  
> > /solink\_health\_monitor/\_mapping to add a timestamp field to the document  
> > \_source
> > 
> > "mappings": {
> > 
> > ```
> > "stats": {
> > 
> > "properties": {
> > 
> > "@timestamp:": {
> > 
> > "enabled": true,
> > 
> > "store": true
> > 
> > }
> > 
> > }
> > 
> > }
> > 
> > ```
> > 
> > }
> > 
> > I get the following response
> > 
> > {
> > 
> > ```
> > "error": "ActionRequestValidationException[Validation 
> > 
> > ```
> > 
> > Failed: 1: mapping type is missing;]",
> > 
> > ```
> > "status": 400
> > 
> > ```
> > 
> > }
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/2fe8afa3-31f7-427b-bc12-48f0c6d49694%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2fe8afa3-31f7-427b-bc12-48f0c6d49694%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/2fe8afa3-31f7-427b-bc12-48f0c6d49694%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/2fe8afa3-31f7-427b-bc12-48f0c6d49694%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > 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/66b983c1-9a80-4f9c-9916-31facf1afb45%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/66b983c1-9a80-4f9c-9916-31facf1afb45%40googlegroups.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:42am UTC](https://discuss.elastic.co/t/cannot-figure-out-how-to-add-automatic-timestamps-when-a-document-is-indexed/21336/5 "2017-07-06T00:42:37Z")

</div>


