Cannot write xcontent for unknown value of type class java.time.OffsetDateTime error

I am able to search from elasticsearch database where the date is between two specified dates

Here is the part of my code

       SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
       searchSourceBuilder.size(10000);
       searchSourceBuilder.query(QueryBuilders.rangeQuery("operation_timestamp_start").gte(date1).lte(date2));
       firstSearchRequest.source(searchSourceBuilder);


Here date1 and date2 variables are java variables of type OffsetDateTime while the operation_timestamp_start variable in elasticsearch databse is of type date.

I am getting the following error - java.lang.IllegalArgumentException: cannot write xcontent for unknown value of type class java.time.OffsetDateTime

Is this because I should use a Date variable instead of offsetDateTime. If yes, how should I accomodate the OffsetDate Part

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