/** * Used to rebuild group information, for example on context which were merged, since merge() of contexts * only merges the Documents with UINFO record (Artifacts). */ public static void rebuildGroups( IndexingContext context ) throws IOException { IndexReader r = context.getIndexReader(); Set<String> rootGroups = new LinkedHashSet<String>(); Set<String> allGroups = new LinkedHashSet<String>(); int numDocs = r.maxDoc(); for ( int i = 0; i < numDocs; i++ ) { if ( r.isDeleted( i ) ) { continue; } Document d = r.document( i ); String uinfo = d.get( ArtifactInfo.UINFO ); if ( uinfo != null ) { ArtifactInfo info = IndexUtils.constructArtifactInfo( d, context ); rootGroups.add( info.getRootGroup() ); allGroups.add( info.groupId ); } } setRootGroups( context, rootGroups ); setAllGroups( context, allGroups ); context.optimize(); }
protected void optimizeIndex( Repository repo ) throws CorruptIndexException, IOException { if ( repo.getRepositoryKind().isFacetAvailable( GroupRepository.class ) ) { GroupRepository group = repo.adaptToFacet( GroupRepository.class ); for ( Repository member : group.getMemberRepositories() ) { optimizeIndex( member ); } } // local IndexingContext context = getRepositoryLocalIndexContext( repo ); if ( context != null ) { getLogger().debug( "Optimizing local index context for repository: " + repo.getId() ); context.optimize(); } // remote context = getRepositoryRemoteIndexContext( repo ); if ( context != null ) { getLogger().debug( "Optimizing remote index context for repository: " + repo.getId() ); context.optimize(); } } }
remoteContext.optimize();
groupContext.optimize();