import static com.google.common.collect.Lists.newArrayList;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.sonar.server.es.Index.ALL_INDICES;
import static org.sonar.server.es.IndexType.FIELD_INDEX_TYPE;
}
public void putDocuments(IndexType indexType, BaseDoc... docs) {
- try {
- BulkRequest bulk = new BulkRequest()
- .setRefreshPolicy(REFRESH_IMMEDIATE);
- for (BaseDoc doc : docs) {
- bulk.add(doc.toIndexRequest());
- }
- BulkResponse bulkResponse = ES_REST_CLIENT.bulk(bulk);
- if (bulkResponse.hasFailures()) {
- throw new IllegalStateException(bulkResponse.buildFailureMessage());
- }
- } catch (Exception e) {
- throw Throwables.propagate(e);
+ BulkRequest bulk = new BulkRequest()
+ .setRefreshPolicy(REFRESH_IMMEDIATE);
+ for (BaseDoc doc : docs) {
+ bulk.add(doc.toIndexRequest());
+ }
+ BulkResponse bulkResponse = ES_REST_CLIENT.bulk(bulk);
+ if (bulkResponse.hasFailures()) {
+ fail("Bulk indexing of documents failed: " + bulkResponse.buildFailureMessage());
}
}