use of org.elasticsearch.index.reindex.BulkByScrollResponse in project incubator-skywalking by apache.
the class ServiceAlarmEsPersistenceDAO method deleteHistory.
@Override
public void deleteHistory(Long startTimestamp, Long endTimestamp) {
long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp);
long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp);
BulkByScrollResponse response = getClient().prepareDelete(QueryBuilders.rangeQuery(ServiceAlarmTable.COLUMN_LAST_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket), ServiceAlarmTable.TABLE).get();
long deleted = response.getDeleted();
logger.info("Delete {} rows history from {} index.", deleted, ServiceAlarmTable.TABLE);
}
use of org.elasticsearch.index.reindex.BulkByScrollResponse in project incubator-skywalking by apache.
the class SegmentEsPersistenceDAO method deleteHistory.
@Override
public void deleteHistory(Long startTimestamp, Long endTimestamp) {
long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp);
long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp);
BulkByScrollResponse response = getClient().prepareDelete(QueryBuilders.rangeQuery(SegmentTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket), SegmentTable.TABLE).get();
long deleted = response.getDeleted();
logger.info("Delete {} rows history from {} index.", deleted, SegmentTable.TABLE);
}
use of org.elasticsearch.index.reindex.BulkByScrollResponse in project core-ng-project by neowu.
the class ElasticSearchTypeImpl method deleteByQuery.
@Override
public long deleteByQuery(DeleteByQueryRequest request) {
if (request.query == null)
throw Exceptions.error("request.query must not be null");
StopWatch watch = new StopWatch();
String index = request.index == null ? this.index : request.index;
long esTookTime = 0;
long deleted = 0;
try {
DeleteByQueryRequestBuilder builder = DeleteByQueryAction.INSTANCE.newRequestBuilder(client());
BulkByScrollResponse response = builder.filter(request.query).source(index).get();
esTookTime = response.getTook().nanos();
deleted = response.getDeleted();
return deleted;
} catch (ElasticsearchException e) {
// due to elastic search uses async executor to run, we have to wrap the exception to retain the original place caused the exception
throw new SearchException(e);
} finally {
long elapsedTime = watch.elapsedTime();
ActionLogContext.track("elasticsearch", elapsedTime, 0, (int) deleted);
logger.debug("deleteByQuery, index={}, type={}, deleted={}, esTookTime={}, elapsedTime={}", index, type, deleted, esTookTime, elapsedTime);
checkSlowOperation(elapsedTime);
}
}
use of org.elasticsearch.index.reindex.BulkByScrollResponse in project vorto by eclipse.
the class ElasticSearchService method deleteByQuery.
private void deleteByQuery(String index, QueryBuilder query) {
logger.info(String.format("Trying to delete all models in index '%s'", index));
DeleteByQueryRequest request = new DeleteByQueryRequest(index);
request.setQuery(query);
try {
BulkByScrollResponse bulkResponse = client.deleteByQuery(request, RequestOptions.DEFAULT);
logger.info(String.format("Deleted %d models in the index '%s'", bulkResponse.getTotal(), index));
} catch (IOException e) {
throw new IndexingException(String.format("Error deleting all models in the '%s' index.", index), e);
}
}
use of org.elasticsearch.index.reindex.BulkByScrollResponse in project incubator-skywalking by apache.
the class InstanceAlarmEsPersistenceDAO method deleteHistory.
@Override
public void deleteHistory(Long startTimestamp, Long endTimestamp) {
long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp);
long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp);
BulkByScrollResponse response = getClient().prepareDelete(QueryBuilders.rangeQuery(InstanceAlarmTable.COLUMN_LAST_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket), InstanceAlarmTable.TABLE).get();
long deleted = response.getDeleted();
logger.info("Delete {} rows history from {} index.", deleted, InstanceAlarmTable.TABLE);
}
Aggregations