I'm stuck with a DateTime formatter problem.
QueryBuilders.constantScoreQuery(FilterBuilders.rangeFilter("lastSeen").lte(
DateTime.now(DateTimeZone.UTC)));
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":{
"constant_score":{"filter":{"range":{"lastSeen":{"from":null,"to":
"2015-02-23T11:18:28.121Z","include_lower":true,"include_upper":true}}}}}}]]
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
.dateTime().withZone(DateTimeZone.UTC);
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.
Thanks
Simon
--
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/ae763740-5ca1-46b6-b09a-c93dbde28427%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.