Search in sources :

Example 1 with BulkUpdate

use of com.b2international.index.BulkUpdate in project snow-owl by b2ihealthcare.

the class DefaultRevisionWriter method setRevised.

private void setRevised(Class<?> type, Set<String> keysToUpdate, final String oldRevised, final String newRevised, RevisionBranchRef branchToUpdate) {
    if (Revision.class.isAssignableFrom(type)) {
        if (!keysToUpdate.isEmpty()) {
            final Map<String, Object> updateRevised = ImmutableMap.of("oldRevised", oldRevised, "newRevised", newRevised);
            for (List<String> keys : Lists.partition(List.copyOf(keysToUpdate), ((EsDocumentSearcher) index.searcher()).maxTermsCount())) {
                final Expression filter = Expressions.builder().filter(Expressions.matchAny(Revision.Fields.ID, keys)).filter(branchToUpdate.toRevisionFilter()).build();
                final BulkUpdate<Revision> update = new BulkUpdate<Revision>((Class<? extends Revision>) type, filter, Revision.UPDATE_REVISED, updateRevised);
                index.bulkUpdate(update);
            }
        }
    } else {
        index.remove(type, keysToUpdate);
    }
}
Also used : Expression(com.b2international.index.query.Expression) BulkUpdate(com.b2international.index.BulkUpdate)

Aggregations

BulkUpdate (com.b2international.index.BulkUpdate)1 Expression (com.b2international.index.query.Expression)1