Getting date parsing exception for milliseconds in a query

(apanimesh061) #1

I the settings of my index I have this field:

"publishedDate": {
  "type": "date",
  "format": "yyyy-MM-dd'T'HH:mm:ssZ",
  "store": true

And in a query I use that field in a Decay function like:

"gauss" : {
  "someField" : {
    "origin" : 1455710259655,
    "scale" : "200dd",
    "decay" : 0.2

But I get the exception:

java.lang.IllegalArgumentException: Invalid format: "1455710259655" is malformed at "9655"

I tried to reproduce this error using joda which handles Date conversions in Elasticsearch:

Long currentMs = new DateTime().getMillis());
DateTimeFormatter currentMsTimeFormat = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ssZ");
DateTime dt = currentMsTimeFormat.parseDateTime(String.valueOf(currentMs));

This snippet also raises the same exception if currentMs is 1455710259655.

I am using ES 2.1.1.

How to solve this issue?

(dick1306) #2

I also met the same problem, can you tell me whether have been solved?

(Jimferenczi) #3

The format parameter of the date field defines how your dates should be parsed. If you define a format like
"yyyy-MM-dd'T'HH:mm:ssZ" then all your inputs for this field should follow this pattern. If you want to use the number of milliseconds since EPOCH you should use "epoch_millis" as the format for your date field.
You can check this page for further information:

(system) #4