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?

1
  • Did you check if your mapping was successful? Did you apply the mapping before inserting any data? Commented Apr 23, 2014 at 15:26

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

3 Comments

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.
I changed my format to 'format' => 'yyyy-MM-dd HH:mm:ss' and this worked for me.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.