use of org.elasticsearch.action.deletebyquery.DeleteByQueryRequestBuilder in project bw-calendar-engine by Bedework.
the class BwIndexEsImpl method unindexEntity.
@Override
public void unindexEntity(final String href) throws CalFacadeException {
try {
final DeleteByQueryRequestBuilder dqrb = getClient().prepareDeleteByQuery(targetIndex);
dqrb.setQuery(QueryBuilders.termQuery(ESQueryFilter.hrefJname, href));
/*final DeleteByQueryResponse resp = */
dqrb.execute().actionGet();
markUpdated(null);
// TODO check response?
} catch (final ElasticsearchException ese) {
// Failed somehow
error(ese);
} catch (final CalFacadeException cfe) {
throw cfe;
} catch (final Throwable t) {
error(t);
throw new CalFacadeException(t);
} finally {
lastIndexTime = System.currentTimeMillis();
}
}
use of org.elasticsearch.action.deletebyquery.DeleteByQueryRequestBuilder 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;
}
Aggregations