# Invalid format of timestamp

**URL:** https://discuss.elastic.co/t/invalid-format-of-timestamp/94238
**Category:** Elasticsearch
**Created:** [July 23, 2017, 11:39am UTC](https://discuss.elastic.co/t/invalid-format-of-timestamp/94238 "2017-07-23T11:39:19Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![marwa](https://avatars.discourse-cdn.com/v4/letter/m/67e7ee/32.png) [@marwa](https://discuss.elastic.co/u/marwa)
#### Post date: [July 23, 2017, 11:39am UTC](https://discuss.elastic.co/t/invalid-format-of-timestamp/94238/1 "2017-07-23T11:39:19Z")

</div>

hi i loaded data in elasticsearch ,this is a sample of it

{"index":{"\_index":"retails","\_type":"information"}}  
{"@timestamp":"11-26-2016","product":{"name":"Bread - French Baquette"},"price":"$424.77","customers":3622,"color":"Fuscia","promotion":{"periode":"01-04-2017"}}

i defined then the mapping as below  
PUT /retail  
{

"mappings" : {  
"information" : {  
"properties" : {  
"@timestamp": {  
"type": "date",  
"format": "mm-dd-yyyy"  
},  
"product" : {  
"properties":{  
"name": {"type" :"text"}  
}  
},

```
"customers" : { "type" : "integer" },
"color":{"type": "text"},
"promotion": {
  "properties":{
    "period": { "type": "date"}
  }
}

```

}  
}

}

}

i loaded data with the command  
curl -XPOST '[http://localhost:9200/\_bulk](http://localhost:9200/_bulk)' --data-binary @retails.json

an error appear  
{"took":454,"errors":true,"items":[{"index":{"\_index":"retail","\_type":"information","\_id":"AV1vGJRJ64LfEy1i7EhN","status":400,"error":{"type":"mapper\_parsing\_exception","reason":"failed to parse [@timestamp]","caused\_by":{"type":"illegal\_argument\_exception","reason":"Invalid format: "05-17-2017" is malformed at "-2017""}}}}

how can i fix this problem !!!

---

<div class="post-metadata">

### Author: ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)
#### Post date: [July 23, 2017, 12:34pm UTC](https://discuss.elastic.co/t/invalid-format-of-timestamp/94238/2 "2017-07-23T12:34:27Z")

</div>

Hi,

Your format is not valid, check here:

[https://www.elastic.co/guide/en/elasticsearch/reference/5.5/mapping-date-format.html#mapping-date-format](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/mapping-date-format.html#mapping-date-format)

and here

[http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html](http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html)

Month is MM

---

<div class="post-metadata">

### Author: ![marwa](https://avatars.discourse-cdn.com/v4/letter/m/67e7ee/32.png) [@marwa](https://discuss.elastic.co/u/marwa)
#### Post date: [July 23, 2017, 12:41pm UTC](https://discuss.elastic.co/t/invalid-format-of-timestamp/94238/3 "2017-07-23T12:41:18Z")

</div>

i changed it into MM-dd-yyy but the same error appears

this is the mapping  
PUT /retail  
{

"mappings" : {  
"information" : {  
"properties" : {  
"@timestamp": {  
"type": "date",  
"format": "MM-dd-yyyy"  
},  
"product" : {  
"properties":{  
"name": {"type" :"text"}  
}  
},

```
"customers" : { "type" : "integer" },
"color":{"type": "text"},
"promotion": {
  "properties":{
    "period": { "type": "date"}
  }
}

```

}  
}

}

}

this is the error  
@timestamp]","caused\_by":{"type":"illegal\_argument\_exception","reason":"Invalid format: "11-26-2016" is malformed at "-26-2016""

---

<div class="post-metadata">

### Author: ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)
#### Post date: [July 23, 2017, 12:44pm UTC](https://discuss.elastic.co/t/invalid-format-of-timestamp/94238/4 "2017-07-23T12:44:26Z")

</div>

Note that if you change your mapping, you have to create a new Index with this mapping.

---

<div class="post-metadata">

### Author: ![marwa](https://avatars.discourse-cdn.com/v4/letter/m/67e7ee/32.png) [@marwa](https://discuss.elastic.co/u/marwa)
#### Post date: [July 23, 2017, 12:45pm UTC](https://discuss.elastic.co/t/invalid-format-of-timestamp/94238/5 "2017-07-23T12:45:19Z")

</div>

i deleted the first one and recreate it

---

<div class="post-metadata">

### Author: ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)
#### Post date: [July 23, 2017, 12:50pm UTC](https://discuss.elastic.co/t/invalid-format-of-timestamp/94238/6 "2017-07-23T12:50:13Z")

</div>

Can you provide result of a GET mapping api on your index plz ?

GET /retail/\_mapping/information

([https://www.elastic.co/guide/en/elasticsearch/reference/5.5/indices-get-mapping.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/indices-get-mapping.html))

---

<div class="post-metadata">

### Author: ![marwa](https://avatars.discourse-cdn.com/v4/letter/m/67e7ee/32.png) [@marwa](https://discuss.elastic.co/u/marwa)
#### Post date: [July 23, 2017, 12:52pm UTC](https://discuss.elastic.co/t/invalid-format-of-timestamp/94238/7 "2017-07-23T12:52:26Z")

</div>

{  
"retail": {  
"mappings": {  
"information": {  
"properties": {  
"@timestamp": {  
"type": "date",  
"format": "MM-dd-yyyy"  
},  
"color": {  
"type": "text"  
},  
"customers": {  
"type": "integer"  
},  
"price": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"product": {  
"properties": {  
"name": {  
"type": "text"  
}  
}  
},  
"promotion": {  
"properties": {  
"period": {  
"type": "date"  
},  
"periode": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
}  
}  
}  
}  
}  
}  
}  
}

this is the result

---

<div class="post-metadata">

### Author: ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)
#### Post date: [July 23, 2017, 12:55pm UTC](https://discuss.elastic.co/t/invalid-format-of-timestamp/94238/8 "2017-07-23T12:55:58Z")

</div>

Seems OK, Can you try to load your datas without the @timestamp field to test if ok ?

---

<div class="post-metadata">

### Author: ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)
#### Post date: [July 23, 2017, 1:06pm UTC](https://discuss.elastic.co/t/invalid-format-of-timestamp/94238/9 "2017-07-23T13:06:21Z")

</div>

Are you putting in the good index ? "retails" vs "retail" ?

---

<div class="post-metadata">

### Author: ![marwa](https://avatars.discourse-cdn.com/v4/letter/m/67e7ee/32.png) [@marwa](https://discuss.elastic.co/u/marwa)
#### Post date: [July 23, 2017, 1:08pm UTC](https://discuss.elastic.co/t/invalid-format-of-timestamp/94238/10 "2017-07-23T13:08:56Z")

</div>

yes , i have just verified the index

---

<div class="post-metadata">

### Author: ![marwa](https://avatars.discourse-cdn.com/v4/letter/m/67e7ee/32.png) [@marwa](https://discuss.elastic.co/u/marwa)
#### Post date: [July 23, 2017, 1:09pm UTC](https://discuss.elastic.co/t/invalid-format-of-timestamp/94238/11 "2017-07-23T13:09:52Z")

</div>

the problem maintains with the timestamp could you give an example of a file containing a timestamp field and how we should map it !!!

---

<div class="post-metadata">

### Author: ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)
#### Post date: [July 23, 2017, 1:47pm UTC](https://discuss.elastic.co/t/invalid-format-of-timestamp/94238/12 "2017-07-23T13:47:21Z")

</div>

I have tested on a 2.4 cluster, here are my commands:

**retails.json**

```
{  
  "mappings":{  
    "information":{  
	"properties":{  
	  "@timestamp":{  
	      "type":"date",
	      "format":"MM-dd-yyyy"
	  },
	  "color":{  
	      "type":"string"
	  },
	  "customers":{  
	      "type":"integer"
	  },
	  "price":{  
	      "type":"string"
	  },
	  "product":{  
	      "properties":{  
		"name":{  
		    "type":"string"
		}
	      }
	  },
	  "promotion":{  
	      "properties":{  
		"period":{  
		    "type":"date"
		},
		"periode":{  
		    "type":"string"
		}
	      }
	  }
	}
    }
  }
}

```

Create an index:

```
curl -XPUT 'http://111.11.11.11:9200/xavier-test-retail' -d @retail.json

```

**retail-data.json**

```
{ "index":{ "_index":"xavier-test-retail", "_type":"information" }}
{ "@timestamp":"11-26-2016", "product":{ "name":"Bread - French Baquette" }, "price":"$424.77", "customers":3622, "color":"Fuscia", "promotion":{ "periode":"01-04-2017" }}

```

Load datas:

```
curl -XPOST 'http://111.11.11.11:9200/_bulk' --data-binary @retail-data.json

```

result:

```
{"took":12,"errors":false,"items":[{"create":{"_index":"xavier-test-retail","_type":"information","_id":"AV1vrlzWBiXCHyywzxDb","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"status":201}}]}

```

Data is correct in the index.

---

<div class="post-metadata">

### Author: ![marwa](https://avatars.discourse-cdn.com/v4/letter/m/67e7ee/32.png) [@marwa](https://discuss.elastic.co/u/marwa)
#### Post date: [July 23, 2017, 2:55pm UTC](https://discuss.elastic.co/t/invalid-format-of-timestamp/94238/13 "2017-07-23T14:55:31Z")

</div>

i did as you did in the last post but when i went to the management tool in kinbana to create an index pattern i couldn't choose time based event

have a look

 ![](https://us1.discourse-cdn.com/elastic/original/3X/2/5/2526ea78565bdd7adca3e2d0ac567d693934a4d4.PNG)  
but i want to creaea an index pattern with time based event

---

<div class="post-metadata">

### Author: ![marwa](https://avatars.discourse-cdn.com/v4/letter/m/67e7ee/32.png) [@marwa](https://discuss.elastic.co/u/marwa)
#### Post date: [July 23, 2017, 3:02pm UTC](https://discuss.elastic.co/t/invalid-format-of-timestamp/94238/14 "2017-07-23T15:02:35Z")

</div>

i did find the problem it is about a bracket in the mapping thank you for your help

---

<div class="post-metadata">

### Author: ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)
#### Post date: [July 23, 2017, 7:59pm UTC](https://discuss.elastic.co/t/invalid-format-of-timestamp/94238/15 "2017-07-23T19:59:54Z")

</div>

Ok cool! You can close this ticket with the solution button.

Nota: $424.77 is very very expensive for a French Baguette !!! 😉

---

<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: [August 20, 2017, 8:00pm UTC](https://discuss.elastic.co/t/invalid-format-of-timestamp/94238/16 "2017-08-20T20:00:04Z")

</div>

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