title: Elasticsearch cannot parse date using custom format
body: <p>According to the documentation (<a href="http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-date-format.html" rel="nofollow">http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-date-format.html</a>), it should be possible to parse dates using a Joda time compatible date pattern.</p>
  
  <p>My data contains dates like this: "2015-02-09 02:10:05,245".</p>
  
  <p>These can be parsed with Joda time using the following pattern: "yyyy-MM-dd HH:mm:ss,SSS".</p>
  
  <p>However, when I tell my index to use this pattern to parse dates, loading data into Elasticsearch fails with the following error:</p>
  
  <pre><code>org.elasticsearch.index.mapper.MapperParsingException: failed to parse [mydate]
      at org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:416)
      at org.elasticsearch.index.mapper.object.ObjectMapper.serializeValue(ObjectMapper.java:709)
      at org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:500)
      at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:542)
      at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:491)
      at org.elasticsearch.index.shard.service.InternalIndexShard.prepareCreate(InternalIndexShard.java:392)
      at org.elasticsearch.action.bulk.TransportShardBulkAction.shardIndexOperation(TransportShardBulkAction.java:444)
      at org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:150)
      at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:512)
      at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:419)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: org.elasticsearch.index.mapper.MapperParsingException: failed to parse date field [2015-02-09 02:10:05,245], tried both date format [dateOptionalTime], and timestamp number with locale []
      at org.elasticsearch.index.mapper.core.DateFieldMapper.parseStringValue(DateFieldMapper.java:621)
      at org.elasticsearch.index.mapper.core.DateFieldMapper.innerParseCreateField(DateFieldMapper.java:549)
      at org.elasticsearch.index.mapper.core.NumberFieldMapper.parseCreateField(NumberFieldMapper.java:235)
      at org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:406)
      ... 12 more
  Caused by: java.lang.IllegalArgumentException: Invalid format: "2015-02-09 02:10:05,245" is malformed at " 02:10:05,245"
      at org.elasticsearch.common.joda.time.format.DateTimeFormatter.parseMillis(DateTimeFormatter.java:754)
      at org.elasticsearch.index.mapper.core.DateFieldMapper.parseStringValue(DateFieldMapper.java:615)
      ... 15 more
  </code></pre>
  
  <p>In the index template, 'mydate' is specified like this:</p>
  
  <pre><code>{
    "template": "te*",
    "mappings": {
      "_default_" : {
        "properties": {
          "mydate": {
            "index": "analyzed",
            "type": "date",
            "format": "yyyy-MM-dd HH:mm:ss,SSS"
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>That should do it, right?</p>