Hello. I have a date field in my documents. Its mapping is:
{
"type" : "date",
"format" : "basic_date_time"
}
I'd like to filter my documents by this date field.
I create filter like this:
val minValue = new org.joda.time.DateTime().minusHours(1)
val maxValue = new org.joda.time.DateTime()
val filter = FilterBuilders.rangeFilter("fieldpath").from(minValue).to(maxValue)
And when executing query with this filter there is an exception:
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:557)
at org.elasticsearch.search.SearchService.createContext(SearchService.java:469)
at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:301)
at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryFetchTransportHandler.messageReceived(SearchServiceTransportAction.java:560)
at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryFetchTransportHandler.messageReceived(SearchServiceTransportAction.java:549)
at org.elasticsearch.transport.netty.MessageChannelHandler$RequestHandler.run(MessageChannelHandler.java:374)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.elasticsearch.ElasticSearchParseException: failed to parse date field [2012-04-24T09:03:10.636+02:00], tried both date format [basic_date_time], and timestamp number
at org.elasticsearch.common.joda.DateMathParser.parseStringValue(DateMathParser.java:194)
at org.elasticsearch.common.joda.DateMathParser.parse(DateMathParser.java:49)
at org.elasticsearch.common.joda.DateMathParser.parse(DateMathParser.java:23)
at org.elasticsearch.index.mapper.core.DateFieldMapper.rangeFilter(DateFieldMapper.java:262)
at org.elasticsearch.index.query.RangeFilterParser.parse(RangeFilterParser.java:119)
at org.elasticsearch.index.query.QueryParseContext.parseInnerFilter(QueryParseContext.java:224)
at org.elasticsearch.index.query.AndFilterParser.parse(AndFilterParser.java:72)
at org.elasticsearch.index.query.QueryParseContext.parseInnerFilter(QueryParseContext.java:224)
at org.elasticsearch.index.query.FilteredQueryParser.parse(FilteredQueryParser.java:68)
at org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:192)
at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:243)
at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:223)
at org.elasticsearch.search.query.QueryParseElement.parse(QueryParseElement.java:33)
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:545)
... 8 more
Caused by: java.lang.IllegalArgumentException: Invalid format: "2012-04-24T09:03:10.636+02:00" is malformed at "-04-24T09:03:10.636+02:00"
at org.elasticsearch.common.joda.time.format.DateTimeFormatter.parseMillis(DateTimeFormatter.java:644)
at org.elasticsearch.common.joda.DateMathParser.parseStringValue(DateMathParser.java:188)
... 21 more
I use Elastic Search 0.19.1.
When changing filter to FilterBuilders.rangeFilter("fieldpath").from(minValue.getMillis()).to(maxValue.getMillis()) it works ok.
By default when you provide Joda date time, it will use the default ISO one
to serialize it. Maybe convert it to basicDateTime yourself and provide the
string value, or get the millis from it and provide it as the from/to.
Hello. I have a date field in my documents. Its mapping is:
{
"type" : "date",
"format" : "basic_date_time"
}
I'd like to filter my documents by this date field.
I create filter like this:
val minValue = new org.joda.time.DateTime().minusHours(1)
val maxValue = new org.joda.time.DateTime()
val filter = FilterBuilders.rangeFilter("fieldpath").from(minValue).to(maxValue)
And when executing query with this filter there is an exception:
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:557)
at org.elasticsearch.search.SearchService.createContext(SearchService.java:469)
at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:301)
at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryFetchTransportHandler.messageReceived(SearchServiceTransportAction.java:560)
at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryFetchTransportHandler.messageReceived(SearchServiceTransportAction.java:549)
at org.elasticsearch.transport.netty.MessageChannelHandler$RequestHandler.run(MessageChannelHandler.java:374)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.elasticsearch.ElasticSearchParseException: failed to parse date field [2012-04-24T09:03:10.636+02:00], tried both date format [basic_date_time], and timestamp number
at org.elasticsearch.common.joda.DateMathParser.parseStringValue(DateMathParser.java:194)
at org.elasticsearch.common.joda.DateMathParser.parse(DateMathParser.java:49)
at org.elasticsearch.common.joda.DateMathParser.parse(DateMathParser.java:23)
at org.elasticsearch.index.mapper.core.DateFieldMapper.rangeFilter(DateFieldMapper.java:262)
at org.elasticsearch.index.query.RangeFilterParser.parse(RangeFilterParser.java:119)
at org.elasticsearch.index.query.QueryParseContext.parseInnerFilter(QueryParseContext.java:224)
at org.elasticsearch.index.query.AndFilterParser.parse(AndFilterParser.java:72)
at org.elasticsearch.index.query.QueryParseContext.parseInnerFilter(QueryParseContext.java:224)
at org.elasticsearch.index.query.FilteredQueryParser.parse(FilteredQueryParser.java:68)
at org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:192)
at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:243)
at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:223)
at org.elasticsearch.search.query.QueryParseElement.parse(QueryParseElement.java:33)
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:545)
... 8 more
Caused by: java.lang.IllegalArgumentException: Invalid format: "2012-04-24T09:03:10.636+02:00" is malformed at "-04-24T09:03:10.636+02:00"
at org.elasticsearch.common.joda.time.format.DateTimeFormatter.parseMillis(DateTimeFormatter.java:644)
at org.elasticsearch.common.joda.DateMathParser.parseStringValue(DateMathParser.java:188)
... 21 more
I use Elastic Search 0.19.1.
When changing filter to FilterBuilders.rangeFilter("fieldpath").from(minValue.getMillis()).to(maxValue.getMillis()) it works ok.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.