Hi,
I am trying to send date range query to the ELS from java app and I create my query using Java API. like as follow:
QueryBuilders.rangeQuery("dateField").from(new Date()).to(new Date())
Just for a test.
But I get an exception due to the NumberFormat, although, from() method accepts Object as the input but it processes just Long.
On the other hand, No way to use Date Math in Java API
Hi,
Thanks for the reply, I use this code exactly in my project and I just noticed it works when we try to connect real running ELS server. But I write test using ELS test framework which uses some embedded stuff to mock the ELS server. In this case, I got the Error. Please find below the error and the generated Query for the timeRange part:
nested: NumberFormatException[For input string: "now"];
at org.elasticsearch.index.query.QueryShardContext.toQuery(QueryShardContext.java:329)
at org.elasticsearch.index.query.QueryShardContext.toQuery(QueryShardContext.java:312)
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:617)
at org.elasticsearch.search.SearchService.createContext(SearchService.java:485)
at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:461)
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:257)
at org.elasticsearch.action.search.SearchTransportService$6.messageReceived(SearchTransportService.java:340)
at org.elasticsearch.action.search.SearchTransportService$6.messageReceived(SearchTransportService.java:337)
at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69)
at org.elasticsearch.transport.TransportService$7.doRun(TransportService.java:644)
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:638)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
By the way, I am using version 6.6.0 of lucene-test-framework
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.