Skip to content

Commit

Permalink
Indexing judgments as individual documents.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzonthemtn committed Dec 4, 2024
1 parent 9607f81 commit 07861f6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,27 +234,20 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli
.source(job)
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);

final AtomicBoolean success = new AtomicBoolean(false);

client.index(indexRequest, new ActionListener<>() {
@Override
public void onResponse(final IndexResponse indexResponse) {
LOGGER.debug("Job completed successfully: {}", jobId);
success.set(true);
LOGGER.debug("Click model job completed successfully: {}", jobId);
}

@Override
public void onFailure(final Exception ex) {
LOGGER.error("Unable to run job with ID {}", jobId, ex);
success.set(false);
throw new RuntimeException("Unable to run job", ex);
}
});

if(success.get()) {
return restChannel -> restChannel.sendResponse(new BytesRestResponse(RestStatus.OK, "{\"judgments_id\": \"" + jobId + "\"}"));
} else {
return restChannel -> restChannel.sendResponse(new BytesRestResponse(RestStatus.INTERNAL_SERVER_ERROR,"Unable to index judgments."));
}
return restChannel -> restChannel.sendResponse(new BytesRestResponse(RestStatus.OK, "{\"judgments_id\": \"" + jobId + "\"}"));

} else {
return restChannel -> restChannel.sendResponse(new BytesRestResponse(RestStatus.BAD_REQUEST, "{\"error\": \"Invalid click model.\"}"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public String indexJudgments(final Collection<Judgment> judgments) throws Except
for(final Judgment judgment : judgments) {

final Map<String, Object> j = judgment.getJudgmentAsMap();
j.put("judgment_id", judgmentsId);
j.put("judgments_id", judgmentsId);

final IndexRequest indexRequest = new IndexRequest(JUDGMENTS_INDEX_NAME)
.id(UUID.randomUUID().toString())
Expand Down

0 comments on commit 07861f6

Please sign in to comment.