Skip to content

Commit

Permalink
Log if bulk indexing fails (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
dr0i committed Aug 18, 2023
1 parent cb1ab1d commit 8e9c359
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/controllers/Index.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
Expand Down Expand Up @@ -206,7 +207,10 @@ static void indexData(final Client aClient, final String aPath,
StandardCharsets.UTF_8))) {
readData(bulkRequest, br, aClient, aIndex);
}
bulkRequest.execute().actionGet();
BulkResponse bulkResponse = bulkRequest.execute().actionGet();
if (bulkResponse.hasFailures()) {
Logger.warn("Bulk insert failed: " + bulkResponse.buildFailureMessage());
}
aClient.admin().indices().refresh(new RefreshRequest()).actionGet();
}

Expand Down

0 comments on commit 8e9c359

Please sign in to comment.