Search in sources :

Example 1 with IndexAdmin

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

the class RepositoryTransactionContext method clearContents.

@Override
public void clearContents() {
    final Index index = service(Index.class);
    final RevisionSearcher revisionSearcher = service(RevisionSearcher.class);
    final IndexAdmin indexAdmin = index.admin();
    final Mappings mappings = indexAdmin.mappings();
    final Stream<Class<?>> revisionTypes = mappings.getTypes().stream().filter(t -> Revision.class.isAssignableFrom(t));
    revisionTypes.forEach(type -> {
        Query.select(String.class).from(type).fields(Revision.Fields.ID).where(Expressions.matchAll()).build().stream(revisionSearcher).forEachOrdered(ids -> {
            final Iterable<?> revisions = fetchComponents(ids.getHits(), type);
            revisions.forEach(rev -> {
                final String revisionId = ((Revision) rev).getId();
                staging.stageRemove(revisionId, rev);
            });
        });
    });
}
Also used : IndexAdmin(com.b2international.index.admin.IndexAdmin) Mappings(com.b2international.index.mapping.Mappings) Index(com.b2international.index.Index)

Aggregations

Index (com.b2international.index.Index)1 IndexAdmin (com.b2international.index.admin.IndexAdmin)1 Mappings (com.b2international.index.mapping.Mappings)1