guys. I've struggled with something really weird. I want to get the result of Elasticsearch query, data(inside source). So this is a part of my code.
SearchResult result = jestClient.execute(search);
JsonObject json = result.getJsonObject();
Map<String, String> map = new HashMap<>();
for (JsonElement jsonElement : json.getAsJsonObject("hits").getAsJsonArray("hits")) {
JsonObject _source = jsonElement.getAsJsonObject().get("_source").getAsJsonObject();
String orderNumber = _source.get("orderNumber").toString();
String equipmentCode = _source.get("equipmentCode").toString();
map.put(orderNumber, equipmentCode);
}
The thing is the value of orderNumber
is "ABCDE"
. What I expected is ABCDE
. (To make it clear, both String contain the double quotes with the value... The funny thing is shown in the debug mode.
I've just checked the values in _source, it has the first value of String "A"
still... but the first value of orderNumber is """
and the second value is "A"... I don't know how to resolve this and anyone helping me?