本文整理汇总了Java中org.apache.lucene.index.IndexWriter.MaxFieldLength类的典型用法代码示例。如果您正苦于以下问题:Java MaxFieldLength类的具体用法?Java MaxFieldLength怎么用?Java MaxFieldLength使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MaxFieldLength类属于org.apache.lucene.index.IndexWriter包,在下文中一共展示了MaxFieldLength类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rollback
import org.apache.lucene.index.IndexWriter.MaxFieldLength; //导入依赖的package包/类
@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();
}
}
示例2: makeDeltaIndexWriter
import org.apache.lucene.index.IndexWriter.MaxFieldLength; //导入依赖的package包/类
/**
* 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;
}
示例3: getIndexWriter
import org.apache.lucene.index.IndexWriter.MaxFieldLength; //导入依赖的package包/类
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);
}
}
示例4: run
import org.apache.lucene.index.IndexWriter.MaxFieldLength; //导入依赖的package包/类
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;
}
示例5: SpatialLuceneExample
import org.apache.lucene.index.IndexWriter.MaxFieldLength; //导入依赖的package包/类
SpatialLuceneExample() throws IOException {
directory = new RAMDirectory();
writer = new IndexWriter(directory, new WhitespaceAnalyzer(Version.LUCENE_41),
MaxFieldLength.UNLIMITED);
}