@RequestBody String body) throws JSONException, UnsupportedEncodingException {
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentType(MediaType.APPLICATION_JSON);
DendriteGraph graph = metaGraphService.getDendriteGraph(graphId);
if (graph == null) {
JSONObject json = new JSONObject();
json.put("status", "error");
json.put("msg", "unknown graph '" + graphId + "'");
return new ResponseEntity<>(json.toString(), responseHeaders, HttpStatus.BAD_REQUEST);
}
Client client = graph.getElasticSearchClient();
if (client == null) {
JSONObject json = new JSONObject();
json.put("status", "error");
json.put("msg", "graph does not have graph elasticsearch index");
return new ResponseEntity<>(json.toString(), responseHeaders, HttpStatus.BAD_REQUEST);
}
SearchResponse response = client.prepareSearch(graph.getIndexName())
.setSource(body)
.execute()
.actionGet();
return new ResponseEntity<>(response.toString(), responseHeaders, HttpStatus.OK);