NumberFormatException in date range aggregation query


(Newbie111985) #1

I have below date range aggregation query:

"Last_Modified_Date": {
"range": {
"field": "lastmodified",
"format": "yyyy-MM-dd",
"ranges": [
{
"to": "now/y"
},
{
"from": "now/y"
},
{
"from": "now-30d/d",
"to": "now/d"
},
{
"from": "now-7d/d",
"to": "now/d"
},
{
"from": "now/d",
"to": "now+1d/d"
}
]
}
}

and this query seems to work fine. But I see below exception in logs:

org.elasticsearch.transport.RemoteTransportException: [examplehost.com][10.248.9.42:9300][indices:data/read/search[phase/query]]
Caused by: java.lang.NumberFormatException: For input string: "now/y"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043) ~[?:1.8.0_121]
at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110) ~[?:1.8.0_121]
at java.lang.Double.parseDouble(Double.java:538) ~[?:1.8.0_121]
at org.elasticsearch.search.DocValueFormat$1.parseDouble(DocValueFormat.java:115) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.search.aggregations.bucket.range.RangeAggregator$Range.process(RangeAggregator.java:124) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.search.aggregations.bucket.range.AbstractRangeBuilder.processRanges(AbstractRangeBuilder.java:69) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.search.aggregations.bucket.range.RangeAggregationBuilder.innerBuild(RangeAggregationBuilder.java:118) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.search.aggregations.bucket.range.RangeAggregationBuilder.innerBuild(RangeAggregationBuilder.java:33) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder.doBuild(ValuesSourceAggregationBuilder.java:300) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder.doBuild(ValuesSourceAggregationBuilder.java:49) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.search.aggregations.AbstractAggregationBuilder.build(AbstractAggregationBuilder.java:126) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.search.aggregations.AggregatorFactories$Builder.build(AggregatorFactories.java:211) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:731) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.search.SearchService.createContext(SearchService.java:553) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:529) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:264) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.action.search.SearchTransportService$6.messageReceived(SearchTransportService.java:300) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.action.search.SearchTransportService$6.messageReceived(SearchTransportService.java:297) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.transport.TransportService$6.doRun(TransportService.java:577) [elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:527) [elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-5.1.2.jar:5.1.2]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_121]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]

lastmodified property mapping is as follows:
"lastmodified": {
"type": "date",
"format": "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
}

What I am doing wrong here? or can this exception be ignored?

Thanks in advance.


(Luca Wintergerst) #2

Hello,
you are using a "range" aggregation instead of the "date_range" aggregation.
Just replace that part of your aggregation and it will work :slight_smile:
Let me know if that works or if you need any more help,

Luca


(Newbie111985) #3

Thanks for your help.


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.