Hello.
I am trying to migrate my java application to use new java api client.
Today I realized that RangeQUeryBuildar has these strange types for gte, lte, etc methods.
Why is it JsonData type?
Range query accepts a number of different types such as string, numbers, date, date math, etc. The Java API client doesn't yet support all these types, and these values have been implemented as raw json data.
This will be improved in a future release. In the meantime, you can pass e.g. a string value (also works for other primitive types) as:
I am using the version 7.15.2 and couldn't figure out how to use RangeQueryBuilder. Currently I am creating a JsonValue object and passing it to Query.Builder 's range method as below:
final String json = "{ \"fld_date\": {\"gte\": \"2018-02-02T15:08:28Z\", \"lte\": \"2021-06-19T16:03:01.130Z\"}}";
final JsonpMapper mapper = new JsonbJsonpMapper();
final JsonParser parser = mapper.jsonProvider().createParser(new StringReader(json));
final JsonData data = JsonData.from(parser, mapper);
final JsonValue value = data.toJson(mapper);
Query.Builder rangeBuilder = new Query.Builder();
rangeBuilder.range(value );
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.