diff --git a/astra/src/main/java/com/slack/astra/bulkIngestApi/BulkIngestApi.java b/astra/src/main/java/com/slack/astra/bulkIngestApi/BulkIngestApi.java index 9d6934df65..9136218735 100644 --- a/astra/src/main/java/com/slack/astra/bulkIngestApi/BulkIngestApi.java +++ b/astra/src/main/java/com/slack/astra/bulkIngestApi/BulkIngestApi.java @@ -81,6 +81,7 @@ public HttpResponse addDocument(String bulkRequest) { BulkIngestResponse response = new BulkIngestResponse(0, 0, "request must contain only 1 unique index"); future.complete(HttpResponse.ofJson(INTERNAL_SERVER_ERROR, response)); + LOG.error("request must contain only 1 unique index"); return HttpResponse.of(future); } diff --git a/astra/src/main/java/com/slack/astra/elasticsearchApi/ElasticsearchApiService.java b/astra/src/main/java/com/slack/astra/elasticsearchApi/ElasticsearchApiService.java index f70e629202..c4c04d1622 100644 --- a/astra/src/main/java/com/slack/astra/elasticsearchApi/ElasticsearchApiService.java +++ b/astra/src/main/java/com/slack/astra/elasticsearchApi/ElasticsearchApiService.java @@ -92,24 +92,30 @@ public HttpResponse clusterMetadata() { @Post @Blocking @Path("/_msearch") - public HttpResponse multiSearch(String postBody) throws Exception { - LOG.debug("Search request: {}", postBody); - - CurrentTraceContext currentTraceContext = Tracing.current().currentTraceContext(); - try (var scope = new StructuredTaskScope()) { - List> requestSubtasks = - openSearchRequest.parseHttpPostBody(postBody).stream() - .map((request) -> scope.fork(currentTraceContext.wrap(() -> doSearch(request)))) - .toList(); - - scope.join(); - SearchResponseMetadata responseMetadata = - new SearchResponseMetadata( - 0, - requestSubtasks.stream().map(StructuredTaskScope.Subtask::get).toList(), - Map.of("traceId", getTraceId())); - return HttpResponse.of( - HttpStatus.OK, MediaType.JSON_UTF_8, JsonUtil.writeAsString(responseMetadata)); + public HttpResponse multiSearch(String postBody) { + + try { + LOG.debug("Search request: {}", postBody); + + CurrentTraceContext currentTraceContext = Tracing.current().currentTraceContext(); + try (var scope = new StructuredTaskScope()) { + List> requestSubtasks = + openSearchRequest.parseHttpPostBody(postBody).stream() + .map((request) -> scope.fork(currentTraceContext.wrap(() -> doSearch(request)))) + .toList(); + + scope.join(); + SearchResponseMetadata responseMetadata = + new SearchResponseMetadata( + 0, + requestSubtasks.stream().map(StructuredTaskScope.Subtask::get).toList(), + Map.of("traceId", getTraceId())); + return HttpResponse.of( + HttpStatus.OK, MediaType.JSON_UTF_8, JsonUtil.writeAsString(responseMetadata)); + } + } catch (Exception e) { + LOG.error("Error fulfilling request for multisearch query", e); + return HttpResponse.of(HttpStatus.INTERNAL_SERVER_ERROR); } }