Package org.apache.lucene.index

Examples of org.apache.lucene.index.IndexWriter.optimize()


        if (t.length() >= 3) {
          Document doc = createDocument(t);
          indexWriter.addDocument(doc);
        }
      }
      indexWriter.optimize();
    } finally {
      if (indexWriter != null) {
        try {
          indexWriter.close();
        } catch (Exception e) {
View Full Code Here


              indexWriter.addDocument(doc);
            }
          }
          aline = dataReader.readLine();
        }
        indexWriter.optimize();
      } finally {
        if (indexWriter != null) {
          try {
            indexWriter.close();
          } catch (Exception e) {
View Full Code Here

      logger.error("Unable to reset the search index. Path "
          + indexDirectory.toString(), e);
    } finally {
      if (writer != null) {
        try {
          writer.optimize();
          writer.close();
        } catch (Exception e) {
          logger.error(e);
        }
      }
View Full Code Here

      if (logger.isDebugEnabled()) {
        logger.debug("Add item " + item + " to index.");
      }
      writer.addDocument(ItemDocument.makeDocument(item));
    }
    writer.optimize();
    nrOfIndexedItems = writer.docCount();
    writer.close();
    logger.info("Finished writing index.");
  }
View Full Code Here

    IndexWriter writer = null;
    try {
      writer = new IndexWriter(dir, analyzer, true);
      writer.setMaxFieldLength(Integer.MAX_VALUE);
      writer.addDocument(doc);
      writer.optimize();
      return dir;
    } catch (IOException e) { // should never happen (RAMDirectory)
      throw new RuntimeException(e);
    } finally {
      try {
View Full Code Here

          indexWriter.addDocument(document);         
        }
        // 6. Close writer
        long startOptimizeTime = 0;
        if (log.isDebug()) startOptimizeTime = System.currentTimeMillis();
        indexWriter.optimize();// TODO:chg: dauert ev. zulange oder nocht noetig
        if (log.isDebug()) log.debug("Optimized in " + (System.currentTimeMillis() - startOptimizeTime) + "ms");
        indexWriter.close();
      } catch (Exception ex) {
        log.warn("Exception during doUpdate. ", ex);
      }
View Full Code Here

        // Merge all part spell indexes (content,title etc.) to one common spell index
        Directory spellIndexDirectory = FSDirectory.open(spellDictionaryFile);//true
        IndexWriter merger = new IndexWriter(spellIndexDirectory, new StandardAnalyzer(Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
        Directory[] directories = { contentSpellIndexDirectory, titleSpellIndexDirectory, descriptionSpellIndexDirectory, authorSpellIndexDirectory};
        merger.addIndexesNoOptimize(directories);
        merger.optimize();
        merger.close();
        spellChecker = new SpellChecker(spellIndexDirectory);
        spellChecker.setAccuracy(0.7f);
         if (log.isDebug()) log.debug("SpellIndex created in " + (System.currentTimeMillis() - startSpellIndexTime) + "ms");
        log.info("New generated Spell-Index ready to use.");
View Full Code Here

      IndexWriter writer = new IndexWriter(ramDir, /*new StandardAnalyzer()/*/XFactory.getWriterAnalyzer());
      Document doc = new Document();
      Field fd = new Field(FIELD_NAME, CONTENT, Field.Store.YES, Field.Index.TOKENIZED,Field.TermVector.WITH_POSITIONS_OFFSETS);
      doc.add(fd);
      writer.addDocument(doc);
      writer.optimize();
      writer.close();
     
      IndexReader reader = IndexReader.open(ramDir);
      String queryString = QUERY;
      QueryParser parser=new QueryParser(FIELD_NAME, /*new StandardAnalyzer()/*/XFactory.getWriterAnalyzer());
 
View Full Code Here

    Document doc = new Document();
    Field fd = new Field(FIELD_NAME, content, Field.Store.YES,
        Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
    doc.add(fd);
    writer.addDocument(doc);
    writer.optimize();
    writer.close();

    IndexReader reader = IndexReader.open(ramDir);
    String queryString = QUERY;
    QueryParser parser = new QueryParser(Version.LUCENE_CURRENT, FIELD_NAME, analyzer);
View Full Code Here

    Document doc = new Document();
    Field fd = new Field(FIELD_NAME, content, Field.Store.YES,
        Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
    doc.add(fd);
    writer.addDocument(doc);
    writer.optimize();
    writer.close();

    IndexReader reader = IndexReader.open(ramDir);
    String queryString = QUERY;
    QueryParser parser = new QueryParser(Version.LUCENE_CURRENT, FIELD_NAME, analyzer);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.