Java 类org.apache.lucene.index.IndexWriter.MaxFieldLength 实例源码

项目:ontobrowser    文件:LuceneIndexWriterXAResource.java   
@Override
public void rollback(Xid xid) throws XAException {
    logger.finest("Rolling back Lucene index writer");

    changeState(xid, EnumSet.of(TransactionState.IDLE,
            TransactionState.PREPARED, TransactionState.ROLLBACK_ONLY), null);

    try {
        Directory directory = writer.getDirectory();
        Analyzer analyzer = writer.getAnalyzer();
        MaxFieldLength maxfieldLength = new MaxFieldLength(writer.getMaxFieldLength()); 

        writer.rollback();

        // IndexWriter.rollback() automatically closes the writer so reopen it.
        logger.finest("Opening new Lucene index writer after rollback");
        writer = new IndexWriter(directory, analyzer, maxfieldLength);
        listener.afterRollback(writer);
    } catch (Exception e) {
        logger.log(Level.WARNING, "Failed to rollback and reopen Lucene index writer", e);
        throw newXAException(XAException.XAER_RMERR, e);
    } finally {
        clearXid();
    }
}
项目:community-edition-old    文件:IndexInfo.java   
/**
 * Make a lucene index writer
 * 
 * @param location File
 * @param analyzer Analyzer
 * @return IndexWriter
 * @throws IOException
 */
private IndexWriter makeDeltaIndexWriter(File location, Analyzer analyzer) throws IOException
{
    IndexWriter writer;
    if (!IndexReader.indexExists(location))
    {
        writer = new IndexWriter(location, analyzer, true, MaxFieldLength.LIMITED);
    }
    else
    {
        writer = new IndexWriter(location, analyzer, false, MaxFieldLength.LIMITED);
    }
    writer.setUseCompoundFile(writerUseCompoundFile);
    writer.setMaxBufferedDocs(writerMaxBufferedDocs);
    writer.setRAMBufferSizeMB(writerRamBufferSizeMb);
    writer.setMergeFactor(writerMergeFactor);
    writer.setMaxMergeDocs(writerMaxMergeDocs);
    writer.setWriteLockTimeout(writeLockTimeout);
    writer.setMaxFieldLength(maxFieldLength);
    writer.setTermIndexInterval(termIndexInterval);
    writer.setMergeScheduler(new SerialMergeScheduler());
    writer.setMergePolicy(new LogDocMergePolicy());
    return writer;

}
项目:restcommander    文件:FilesystemStore.java   
private IndexWriter getIndexWriter(String name) {
    try {
        if (!indexWriters.containsKey(name)) {
            synchronized (this) {
                File root = new File(DATA_PATH, name);
                if (!root.exists())
                    root.mkdirs();
                if (new File(root, "write.lock").exists())
                    new File(root, "write.lock").delete();
                IndexWriter writer = new IndexWriter(FSDirectory.open(root), Search.getAnalyser(), MaxFieldLength.UNLIMITED);
                indexWriters.put(name, writer);
            }
        }
        return indexWriters.get(name);
    } catch (Exception e) {
        throw new UnexpectedException(e);
    }
}
项目:eclipsensis    文件:NSISHelpIndexer.java   
public IStatus run(IProgressMonitor monitor)
    {
        IndexWriter writer = null;
        IStatus status = Status.OK_STATUS;
        try {
            monitor.beginTask(EclipseNSISPlugin.getResourceString("nsis.help.indexer.task.title"),IProgressMonitor.UNKNOWN); //$NON-NLS-1$
            if(mIndexLocation.exists()) {
                mIndexLocation.mkdirs();
            }
writer = new IndexWriter(new SimpleFSDirectory(mIndexLocation),
        mAnalyzer, true, MaxFieldLength.LIMITED);
            writer.setMaxFieldLength(1000000);

            status = indexDocs(monitor, writer, mDocumentRoot);
            if(status.isOK()) {
                writer.optimize();
            }
        }
        catch(Exception ex) {
            EclipseNSISPlugin.getDefault().log(ex);
            status = new Status(IStatus.ERROR, INSISConstants.PLUGIN_ID, IStatus.ERROR, ex.getMessage(), ex);
            IOUtility.deleteDirectory(mIndexLocation);
        }
        finally {
            if(writer != null) {
                try {
                    writer.close();
                }
                catch (IOException e) {
                    EclipseNSISPlugin.getDefault().log(e);
                }
            }
            monitor.done();
            if(monitor.isCanceled()) {
                status = Status.CANCEL_STATUS;
                IOUtility.deleteDirectory(mIndexLocation);
            }
        }
        return status;
    }
项目:t4f-data    文件:SpatialLuceneExample.java   
SpatialLuceneExample() throws IOException {
  directory = new RAMDirectory();
  writer = new IndexWriter(directory, new WhitespaceAnalyzer(Version.LUCENE_41),
                           MaxFieldLength.UNLIMITED);
}