use of org.molgenis.data.index.exception.UnknownIndexException in project molgenis by molgenis.
the class ClientFacade method deleteById.
public void deleteById(Index index, Document document) {
if (LOG.isTraceEnabled()) {
LOG.trace("Deleting doc with id '{}' in index '{}' ...", document.getId(), index.getName());
}
String indexName = index.getName();
String documentId = document.getId();
DeleteRequestBuilder deleteRequest = client.prepareDelete().setIndex(indexName).setType(indexName).setId(documentId);
DeleteResponse deleteResponse;
try {
deleteResponse = deleteRequest.get();
} catch (ResourceNotFoundException e) {
LOG.error("", e);
throw new UnknownIndexException(index.getName());
} catch (ElasticsearchException e) {
LOG.debug("", e);
throw new IndexException(format("Error deleting doc with id '%s' in index '%s'.", documentId, indexName));
}
if (LOG.isDebugEnabled()) {
LOG.debug("Deleted doc with id '{}' in index '{}' and status '{}'", documentId, indexName, deleteResponse.getResult());
}
}
use of org.molgenis.data.index.exception.UnknownIndexException in project molgenis by molgenis.
the class ClientFacade method refreshIndexes.
private void refreshIndexes(List<Index> indexes) {
if (LOG.isTraceEnabled()) {
LOG.trace("Refreshing index(es) '{}' ...", toString(indexes));
}
String[] indexNames = toIndexNames(indexes);
RefreshRequestBuilder refreshRequest = client.admin().indices().prepareRefresh(indexNames);
RefreshResponse refreshResponse;
try {
refreshResponse = refreshRequest.get();
} catch (ResourceNotFoundException e) {
LOG.debug("", e);
throw new UnknownIndexException(toIndexNames(indexes));
} catch (ElasticsearchException e) {
LOG.error("", e);
throw new IndexException(format("Error refreshing index(es) '%s'.", toString(indexes)));
}
if (refreshResponse.getFailedShards() > 0) {
LOG.error(stream(refreshResponse.getShardFailures()).map(ShardOperationFailedException::toString).collect(joining("\n")));
throw new IndexException(format("Error refreshing index(es) '%s'.", toString(indexes)));
}
if (LOG.isDebugEnabled()) {
LOG.debug("Refreshed index(es) '{}'", toString(indexes));
}
}
Aggregations