forceMerge(maxNumSegments, true);
public void admin(final HttpServletRequest req, final HttpServletResponse resp) throws IOException, JSONException { final IndexState state = getState(req, resp); if (state == null) return; final String command = new PathParts(req).getCommand(); if ("_expunge".equals(command)) { logger.info("Expunging deletes from " + state); state.writer.forceMergeDeletes(false); resp.setStatus(202); ServletUtils.sendJsonSuccess(req, resp); return; } if ("_optimize".equals(command)) { logger.info("Optimizing " + state); state.writer.forceMerge(1, false); resp.setStatus(202); ServletUtils.sendJsonSuccess(req, resp); return; } ServletUtils.sendJsonError(req, resp, 400, "bad_request"); }
/** * Commits all index partitions. * * @param merge also merge all segments together. This should be done before reading term frequencies. * @throws IOException on Lucene I/O error. */ public void flush( boolean merge ) throws IOException { List<AbstractIndexPartition> partitions = getPartitions(); for ( AbstractIndexPartition partition : partitions ) { IndexWriter writer = partition.getIndexWriter(); writer.commit(); if ( merge ) { writer.forceMerge( 1 ); } } }
indexWriter.maybeMerge(); } else { indexWriter.forceMerge(maxNumSegments, true /* blocks and waits for merges*/);
wrt.forceMerge(1); // this is deprecated and not needed anymore elapsed.report(LOGGER, String.format("Done optimizing index%s", projectDetail)); synchronized (lock) {
/** * Optimizes an index. * * @param iw * @throws IOException */ public static void optimizeWriter(IndexWriter iw) throws IOException { iw.forceMerge(1); }
/** * Optimizes an index. * * @param iw * @throws IOException */ public static void optimizeWriter(IndexWriter iw) throws IOException { iw.forceMerge(1); }
infoStream.message(LOG_PREFIX, "Upgrading all pre-" + Version.LATEST + " segments of index directory '" + dir + "' to version " + Version.LATEST + "..."); w.forceMerge(1); if (infoStream.isEnabled(LOG_PREFIX)) { infoStream.message(LOG_PREFIX, "All segments upgraded to version " + Version.LATEST);
public void perform(IndexWriter writer) throws IOException { // http://www.searchworkings.org/blog/-/blogs/simon-says%3A-optimize-is-bad-for-you writer.forceMerge(1); } });
@Override public void close() throws IOException { indexWriter.forceMerge(1); indexWriter.close(); } }
@Override public void forceMerge(int maxNumSegments) throws IOException { try (Ticker ignored = mergeDocumentsMetric.start()) { super.forceMerge(maxNumSegments); } }
@Override public void forceMerge(int maxNumSegments, boolean doWait) throws IOException { try (Ticker ignored = mergeDocumentsMetric.start()) { super.forceMerge(maxNumSegments, doWait); } }
/** * Index optimization using {@link IndexWriter#optimize()} method. */ public void optimize() throws CorruptIndexException, IOException { for (PersistentIndex index : indexes) { IndexWriter writer = index.getIndexWriter(); writer.forceMerge(1, true); } }
public void commitChanges() { try { final IndexWriter writer = getWriter(); if (writer != null) { writer.forceMerge(Integer.MAX_VALUE); writer.commit(); } } catch (IOException e) { LOGGER.error(e.getMessage(), e); } }
public void optimize() throws IOException { lastChange = System.currentTimeMillis(); indexWriter.forceMerge(1); forceCommit(); }
private CompletableFuture<Long> commitIndex(IndexWriter indexWriter) { try { indexWriter.forceMerge( 1 ); return CompletableFuture.completedFuture( indexWriter.commit() ); } catch (IOException e) { throw log.unableToCommitIndex( getEventContext(), e ); } }
@Override public int doLogic() throws Exception { if (maxNumSegments == -1) { throw new IllegalStateException("required argument (maxNumSegments) was not specified"); } IndexWriter iw = getRunData().getIndexWriter(); iw.forceMerge(maxNumSegments); //System.out.println("forceMerge called"); return 1; }
public synchronized void optimize() throws CorruptIndexException, IOException { getIndexWriter().forceMerge(1); commit(); }
/** * Blocks and waits until all write operations to the index complete. Optimizes the index while holding the write * lock to ensure no concurrent modifications. Optimize is done using interactive mode configuration. */ public void optimize() throws LuceneException { try (Ticker ignored = optimizeMetric.start()) { withWriter(writer -> { writer.forceMerge(1, true); // contract of this method says to block until completion }); } }
/** * Optimizing an index is not recommended nowadays, still it's an interesting * byte-shuffling exercise to test. */ public static void optimizeIndex(Directory dir) throws IOException { IndexWriterConfig indexWriterConfig = new IndexWriterConfig(LuceneSettings.analyzer); IndexWriter iw = new IndexWriter(dir, indexWriterConfig); iw.forceMerge(1, true); iw.close(); }