congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
IndexWriter.close
Code IndexAdd Tabnine to your IDE (free)

How to use
close
method
in
org.apache.lucene.index.IndexWriter

Best Java code snippets using org.apache.lucene.index.IndexWriter.close (Showing top 20 results out of 2,088)

Refine searchRefine arrow

  • IndexWriter.<init>
origin: opentripplanner/OpenTripPlanner

final IndexWriter writer = new IndexWriter(directory, config);
for (Stop stop : graphIndex.stopForId.values()) {
  addStop(writer, stop);
  addCorner(writer, sv);
writer.close();
long elapsedTime = System.currentTimeMillis() - startTime;
LOG.info("Built Lucene index in {} msec", elapsedTime);
origin: oracle/opengrok

conf.setOpenMode(OpenMode.CREATE_OR_APPEND);
wrt = new IndexWriter(indexDirectory, conf);
wrt.forceMerge(1); // this is deprecated and not needed anymore
elapsed.report(LOGGER, String.format("Done optimizing index%s", projectDetail));
if (wrt != null) {
  try {
    wrt.close();
  } catch (IOException e) {
    if (writerException == null) {
origin: FudanNLP/fnlp

IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_47, analyzer);
iwc.setOpenMode(OpenMode.CREATE_OR_APPEND);
IndexWriter writer = new IndexWriter(dir, iwc);
writer.close();
origin: oracle/opengrok

writer = new IndexWriter(indexDirectory, iwc);
try {
  if (writer != null) {
    writer.close();
origin: ahmetaa/zemberek-nlp

public void addCorpora(List<Path> corpora, double ramBufferInMb) throws IOException {
 Directory dir = FSDirectory.open(indexPath);
 Analyzer analyzer = CustomAnalyzer.builder()
   .withTokenizer("standard")
   .addTokenFilter(LuceneLemmaFilter.Factory.class)
   .build();
 IndexWriterConfig iwc = new IndexWriterConfig(analyzer);
 iwc.setOpenMode(OpenMode.CREATE_OR_APPEND);
 iwc.setRAMBufferSizeMB(ramBufferInMb);
 IndexWriter writer = new IndexWriter(dir, iwc);
 for (Path path : corpora) {
  Log.info("Adding %s", path);
  addDocs(writer, path);
 }
 writer.close();
}
origin: Impetus/Kundera

w.close();
IndexWriterConfig indexWriterConfig = new IndexWriterConfig(analyzer);
LogDocMergePolicy logDocMergePolicy = new LogDocMergePolicy();
logDocMergePolicy.setMergeFactor(1000);
indexWriterConfig.setMergePolicy(logDocMergePolicy);
w = new IndexWriter(index, indexWriterConfig);
origin: org.elasticsearch/elasticsearch

IndexWriter writer = new IndexWriter(store.directory(), new IndexWriterConfig(null)
  .setSoftDeletesField(Lucene.SOFT_DELETES_FIELD)
  .setOpenMode(IndexWriterConfig.OpenMode.CREATE)
  .setCommitOnClose(true));
writer.close();
return;
origin: org.compass-project/compass

  /**
   * Removes all terms from the spell check index.
   * @throws IOException
   */
  public void clearIndex() throws IOException {
   IndexWriter writer = new IndexWriter(spellIndex, null, true);
   writer.close();

    // COMASS: Remove closing the searcher
   //close the old searcher
//      searcher.close();
//      searcher = new IndexSearcher(this.spellIndex);
  }

origin: riotfamily/riot

public void crawlerFinished() {
  try {
    tempWriter.close();
    IndexWriter indexWriter = new IndexWriter(indexDir, null, true);
    indexWriter.addIndexes(new Directory[] { tempIndexDir });
    indexWriter.close();
  }
  catch (IOException e) {
    log.error("Error", e);
  }
  tempWriter = null;
}
origin: org.apache.portals.jetspeed-2/jetspeed-search

private boolean optimizeIndex() {
  boolean result = false;
  try {
    IndexWriter indexWriter = new IndexWriter(directory, analyzer, false, IndexWriter.MaxFieldLength.UNLIMITED);
    indexWriter.optimize();
    indexWriter.close();
    result = true;
  } catch (IOException e) {
    //logger.error("Error while trying to optimize index.");
  }
  return result;
}
origin: mkalus/segrada

@Override
public synchronized void clearAllIndexes() {
  try {
    // init index writer config
    IndexWriterConfig indexWriterConfig = new IndexWriterConfig(this.analyzer);
    // create new index writer
    IndexWriter iWriter = new IndexWriter(directory, indexWriterConfig);
    iWriter.deleteAll();
    iWriter.close();
  } catch (Exception e) {
    logger.warn("Error while deleting all entries", e);
  }
}
origin: com.atlassian.bonnie/atlassian-bonnie

/**
 * Ensures the index directory exists, contains a Lucene index, and is available
 * for writing.
 */
private void ensureIndexExists(Directory directory) throws IOException {
  indexWriteLock.lock();
  try {
    if (!DirectoryReader.indexExists(directory)) {
      new IndexWriter(directory, new IndexWriterConfig(BonnieConstants.LUCENE_VERSION, null)).close();
    }
  } finally {
    indexWriteLock.unlock();
  }
}
origin: com.atlassian.bonnie/atlassian-bonnie

private static void upgradeIndexIfNecessary(File directoryPath, Directory directory) throws IOException {
  try {
    new IndexWriter(directory, new IndexWriterConfig(BonnieConstants.LUCENE_VERSION, null)).close();
  } catch (IndexFormatTooOldException e) {
    log.info("Detected old index format. Attempting an upgrade.");
    upgradeIndexToLucene36(directoryPath);
    upgradeIndexToCurrentLuceneVersion(directory);
  }
}
origin: org.compass-project/compass

public synchronized void createIndex(String subContext, String subIndex) throws SearchEngineException {
  Directory dir = openDirectory(subContext, subIndex);
  try {
    IndexWriter indexWriter = new IndexWriter(dir, new StandardAnalyzer(), true);
    indexWriter.close();
  } catch (IOException e) {
    throw new SearchEngineException("Failed to create index for sub index [" + subIndex + "]", e);
  }
}
origin: org.talend.dataquality/dataquality-semantic

/**
 * create a lucene RAMDirectory from a list of BroadcastDocumentObject
 */
static RAMDirectory createRamDirectoryFromDocuments(List<BroadcastDocumentObject> dictionaryObject) throws IOException {
  RAMDirectory ramDirectory = new RAMDirectory();
  IndexWriterConfig writerConfig = new IndexWriterConfig(Version.LATEST, new StandardAnalyzer(CharArraySet.EMPTY_SET));
  IndexWriter writer = new IndexWriter(ramDirectory, writerConfig);
  for (BroadcastDocumentObject objectDoc : dictionaryObject) {
    writer.addDocument(BroadcastUtils.createLuceneDocumentFromObject(objectDoc));
  }
  writer.commit();
  writer.close();
  return ramDirectory;
}
origin: org.apache.servicemix/servicemix-audit

/**
 * Add object to Lucene index
 */
public void add(Document lucDoc, String id) throws IOException {
  synchronized (directory) {
    IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), !segmentFile.exists());
    try {
      writer.addDocument(lucDoc);
    } finally {
      writer.close();
    }
  }
}
origin: eu.fbk.twm/twm-index

  public static void main(String[] args) {
    String index = args[0];
    try {
      IndexWriter i = new IndexWriter(FSDirectory.open(new File(index)), new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
      i.optimize();
      i.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-sail-lucene

private void postInit()
  throws IOException
{
  this.queryAnalyzer = new StandardAnalyzer();
  // do some initialization for new indices
  if (!DirectoryReader.indexExists(directory)) {
    logger.debug("creating new Lucene index in directory {}", directory);
    IndexWriterConfig indexWriterConfig = getIndexWriterConfig();
    indexWriterConfig.setOpenMode(OpenMode.CREATE);
    IndexWriter writer = new IndexWriter(directory, indexWriterConfig);
    writer.close();
  }
}
origin: net.sf.lucis/lucis-core

  private static synchronized void create() throws IOException {
    if (directory != null) {
      return;
    }
    final RAMDirectory ram = new RAMDirectory();
    IndexWriter w = new IndexWriter(ram, Factory.get().writerConfig());
    w.commit();
    w.close();
    directory = ram;
  }
}
origin: com.atlassian.jira/jira-tests

public static Directory getCleanRAMDirectory()
{
  try
  {
    final Directory directory = new RAMDirectory();
    IndexWriterConfig conf = new IndexWriterConfig(LuceneVersion.get(), new StandardAnalyzer(LuceneVersion.get()));
    conf.setOpenMode(IndexWriterConfig.OpenMode.CREATE);
    new IndexWriter(directory, conf).close();
    return directory;
  }
  catch (final IOException e)
  {
    throw new RuntimeException(e);
  }
}
org.apache.lucene.indexIndexWriterclose

Javadoc

Closes all open resources and releases the write lock. If IndexWriterConfig#commitOnClose is true, this will attempt to gracefully shut down by writing any changes, waiting for any running merges, committing, and closing. In this case, note that:
  • If you called prepareCommit but failed to call commit, this method will throw IllegalStateException and the IndexWriterwill not be closed.
  • If this method throws any other exception, the IndexWriterwill be closed, but changes may have been lost.

Note that this may be a costly operation, so, try to re-use a single writer instead of closing and opening a new one. See #commit() for caveats about write caching done by some IO devices.

NOTE: You must ensure no other threads are still making changes at the same time that this method is invoked.

Popular methods of IndexWriter

  • <init>
    Expert: constructs an IndexWriter with a custom IndexDeletionPolicy, for the index in d. Text will b
  • addDocument
    Adds a document to this index, using the provided analyzer instead of the value of #getAnalyzer(). I
  • commit
  • deleteDocuments
    Deletes the document(s) matching any of the provided queries. All deletes are flushed at the same ti
  • updateDocument
    Updates a document by first deleting the document(s) containing term and then adding the new documen
  • forceMerge
    Just like #forceMerge(int), except you can specify whether the call should block until all merging c
  • deleteAll
    Delete all documents in the index. This method will drop all buffered documents and will remove all
  • optimize
    Just like #optimize(), except you can specify whether the call should block until the optimize compl
  • rollback
    Close the IndexWriter without committing any changes that have occurred since the last commit (or si
  • addIndexes
    Merges all segments from an array of indexes into this index.
  • getConfig
    Returns a LiveIndexWriterConfig, which can be used to query the IndexWriter current settings, as wel
  • getDirectory
    Returns the Directory used by this index.
  • getConfig,
  • getDirectory,
  • addDocuments,
  • isOpen,
  • isLocked,
  • numDocs,
  • unlock,
  • flush,
  • forceMergeDeletes

Popular in Java

  • Finding current android device location
  • getSharedPreferences (Context)
  • findViewById (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now