| I found some time to further investigate and figured out that the problem is actually related to the Jest client. When the search request uses one or more sort fields, Jest deserializes the json into a map, adds some sort stuff and serializes the map back to json (looks a bit ugly to me). In the deserialization step all number values are converted to a Double, and gson then uses the scientific notation when serializing that Double back to json. See io.searchbox.core.Search::getData The following code snippet...
Gson gson = new GsonBuilder().create();
String query = "{\"range\":{\"createdAt\":{\"gte\":1478789928000}}}";
Map map = gson.fromJson(query, Map.class);
String data = gson.toJson(map);
System.out.println(data);
...results into this:
{"range":{"createdAt":{"gte":1.478789928E12}}}
If we have a look inside the map...
Map<String, Map<String, Map>> map = gson.fromJson(query, Map.class);
System.out.println(map.get("range").get("createdAt").get("gte").getClass());
...we can see there's a double inside:
When I register a custom type converter for Doubles...
Gson gson = new GsonBuilder()
.registerTypeAdapter(Double.class, (JsonSerializer<Double>)(src, type, ctx) ->
new JsonPrimitive(new BigDecimal(BigDecimal.valueOf(src).toBigIntegerExact()))
)
.create();
...I can avoid the scientific notation and get this result instead:
{"range":{"createdAt":{"gte":1478789928000}}}
|