Java Client API: DateTime format for QueryBuilders/FilterBuilders

I'm stuck with a DateTime formatter problem.


According to my doc type mapping, the field "lastSeen" is of type "date"
with format "date_time_no_millis". Executing the defined query will leave
me with a parse failure, because the Joda DateTime object was serialized in
an unexpected format.

Parse Failure [Failed to parse source [{"from":0,"size":0,"query":{
org.elasticsearch.ElasticsearchParseException: failed to parse date field [
2015-02-23T11:18:28.121Z], tried both date format [date_time_no_millis], and
timestamp number

Well the format is not really unexpected, it's the default format the
XContentBuilder is using, but it's still not the format the server is
expecting, according to the mapping.

public final static DateTimeFormatter defaultDatePrinter = ISODateTimeFormat

The question now is, is there a way to overwrite the default formatter and
define the format it should use or maybe a setting to make the client aware
of the doc type mapping?
The only solution I found so far is serializing in the correct format on my
own and passing a String instead of a DateTime object. But I figure there
must be a better solution.

I'm on ElasticSearch 1.3.7.


You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
For more options, visit