0

First time using ElasticSearch, I'm having trouble indexing a document due to the mapping of dates.

in my DB dates are DATETIME and look like this 2014-02-04 14:04:39. I'm trying to parse this in ElasticSearch but it's telling me that

[Invalid format: \"2014-02-04 14:04:39\" is malformed at \" 14:04:39\"]

I've tried setting the format quite a few different ways:

'date_added' => array(
        'type' => 'date',
        'format' => 'yyyy-MM-dd HH:mm:ss'
        )

and also like this:

yyyy-MM-ddTHH:mm:ss

yyyy-MM-ddTHH:mm:ssZZ

What is the correct format for this?

Jonnny
  • 4,939
  • 11
  • 63
  • 93

1 Answers1

1

In mapping, configure the field to date and also the format you need.. For syntax refer

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html#date

The date format that are supported by elasticsearch refer the following link..

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-date-format.html

BlackPOP
  • 5,657
  • 2
  • 33
  • 49
  • thanks for those, I had looked at them but I don't see what is wrong with my format that I've tried. But obviously it is wrong, but I don't know what the correct format should be. – Jonnny Apr 23 '14 at 19:17
  • To change mapping.. Refer http://stackoverflow.com/questions/23238972/how-to-do-mapping-while-indexing-in-elasticsearch/23241214#23241214 – BlackPOP Apr 24 '14 at 03:01
  • I changed my format to `'format' => 'yyyy-MM-dd HH:mm:ss'` and this worked for me. – Jonnny Apr 26 '14 at 21:35