public MultiSearchResponse(JsonObject jsonObject) { final JsonElement error = jsonObject.get(ERROR_KEY); if(error != null) { this.isError = true; this.error = error; if (error.isJsonPrimitive()) { this.errorMessage = error.getAsString(); } else if (error.isJsonObject()){ this.errorMessage = error.getAsJsonObject().get("reason").getAsString(); } else { this.errorMessage = error.toString(); } this.searchResult = null; } else { this.isError = false; this.errorMessage = null; this.error = JsonNull.INSTANCE; this.searchResult = new SearchResult(gson); this.searchResult.setSucceeded(true); this.searchResult.setResponseCode(responseCode); this.searchResult.setJsonObject(jsonObject); this.searchResult.setJsonString(jsonObject.toString()); this.searchResult.setPathToResult("hits/hits/_source"); } } }
public MultiSearchResponse(JsonObject jsonObject) { final JsonElement error = jsonObject.get(ERROR_KEY); if(error != null) { this.isError = true; this.error = error; if (error.isJsonPrimitive()) { this.errorMessage = error.getAsString(); } else if (error.isJsonObject()){ this.errorMessage = error.getAsJsonObject().get("reason").getAsString(); } else { this.errorMessage = error.toString(); } this.searchResult = null; } else { this.isError = false; this.errorMessage = null; this.error = JsonNull.INSTANCE; this.searchResult = new SearchResult(gson); this.searchResult.setSucceeded(true); this.searchResult.setResponseCode(responseCode); this.searchResult.setJsonObject(jsonObject); this.searchResult.setJsonString(jsonObject.toString()); this.searchResult.setPathToResult("hits/hits/_source"); } } }
public MultiSearchResponse(JsonNode jsonObject) { final JsonNode error = jsonObject.get(ERROR_KEY); if (error != null) { this.isError = true; this.error = error; this.errorMessage = error.path("reason").asText(); this.searchResult = null; } else { this.isError = false; this.errorMessage = null; this.error = MissingNode.getInstance(); this.searchResult = new SearchResult(objectMapper); this.searchResult.setSucceeded(true); this.searchResult.setResponseCode(responseCode); this.searchResult.setJsonObject(jsonObject); this.searchResult.setJsonString(jsonObject.toString()); this.searchResult.setPathToResult("hits/hits/_source"); } } }