Search in sources :

Example 1 with IndexDeleteByQueryResponse

use of org.elasticsearch.action.deletebyquery.IndexDeleteByQueryResponse in project bw-calendar-engine by Bedework.

the class BwIndexEsImpl method deleteEvent.

private boolean deleteEvent(final String href) throws CalFacadeException {
    final DeleteByQueryRequestBuilder delQreq = getClient().prepareDeleteByQuery(targetIndex).setTypes(docTypeEvent, docTypePoll);
    final ESQueryFilter esq = getFilters(null);
    final FilterBuilder fb = esq.addTerm(PropertyInfoIndex.HREF, href);
    delQreq.setQuery(QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), fb));
    final DeleteByQueryResponse delResp = delQreq.execute().actionGet();
    boolean ok = true;
    for (final IndexDeleteByQueryResponse idqr : delResp.getIndices().values()) {
        if (idqr.getFailedShards() > 0) {
            warn("Failing shards for delete href: " + href + " index: " + idqr.getIndex());
            ok = false;
        }
    }
    return ok;
}
Also used : DeleteByQueryResponse(org.elasticsearch.action.deletebyquery.DeleteByQueryResponse) IndexDeleteByQueryResponse(org.elasticsearch.action.deletebyquery.IndexDeleteByQueryResponse) TermFilterBuilder(org.elasticsearch.index.query.TermFilterBuilder) FilterBuilder(org.elasticsearch.index.query.FilterBuilder) DeleteByQueryRequestBuilder(org.elasticsearch.action.deletebyquery.DeleteByQueryRequestBuilder) IndexDeleteByQueryResponse(org.elasticsearch.action.deletebyquery.IndexDeleteByQueryResponse)

Aggregations

DeleteByQueryRequestBuilder (org.elasticsearch.action.deletebyquery.DeleteByQueryRequestBuilder)1 DeleteByQueryResponse (org.elasticsearch.action.deletebyquery.DeleteByQueryResponse)1 IndexDeleteByQueryResponse (org.elasticsearch.action.deletebyquery.IndexDeleteByQueryResponse)1 FilterBuilder (org.elasticsearch.index.query.FilterBuilder)1 TermFilterBuilder (org.elasticsearch.index.query.TermFilterBuilder)1