本文整理汇总了C#中Lucene.Net.Index.IndexWriter.SetMaxFieldLength方法的典型用法代码示例。如果您正苦于以下问题:C# IndexWriter.SetMaxFieldLength方法的具体用法?C# IndexWriter.SetMaxFieldLength怎么用?C# IndexWriter.SetMaxFieldLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Index.IndexWriter
的用法示例。
在下文中一共展示了IndexWriter.SetMaxFieldLength方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LuceneMetadataRepository
public LuceneMetadataRepository()
{
_analyzer = new StandardAnalyzer();
_directory = FSDirectory.GetDirectory("./index", true);
_indexWriter = new IndexWriter(_directory, _analyzer, true);
_indexWriter.SetMaxFieldLength(25000);
_indexSearcher = new IndexSearcher(_directory);
}
示例2: Index
public void Index()
{
Directory directory = FSDirectory.GetDirectory("./index", true);
var iwriter = new IndexWriter(directory, _analyzer, true);
iwriter.SetMaxFieldLength(25000);
var x = Repository.List();
foreach (var package in x)
{
var doc = new Document();
doc.Add(new Field("name", package.Name, Field.Store.YES, Field.Index.TOKENIZED));
doc.Add(new Field("description", package.Description, Field.Store.YES, Field.Index.TOKENIZED));
iwriter.AddDocument(doc);
}
iwriter.Close();
}
示例3: TestHighFreqTerm
public virtual void TestHighFreqTerm()
{
RAMDirectory dir = new RAMDirectory();
IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true);
writer.SetRAMBufferSizeMB(0.01);
writer.SetMaxFieldLength(100000000);
// Massive doc that has 128 K a's
System.Text.StringBuilder b = new System.Text.StringBuilder(1024 * 1024);
for (int i = 0; i < 4096; i++)
{
b.Append(" a a a a a a a a");
b.Append(" a a a a a a a a");
b.Append(" a a a a a a a a");
b.Append(" a a a a a a a a");
}
Document doc = new Document();
doc.Add(new Field("field", b.ToString(), Field.Store.YES, Field.Index.TOKENIZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
writer.AddDocument(doc);
writer.Close();
IndexReader reader = IndexReader.Open(dir);
Assert.AreEqual(1, reader.MaxDoc());
Assert.AreEqual(1, reader.NumDocs());
Term t = new Term("field", "a");
Assert.AreEqual(1, reader.DocFreq(t));
TermDocs td = reader.TermDocs(t);
td.Next();
Assert.AreEqual(128 * 1024, td.Freq());
reader.Close();
dir.Close();
}
示例4: Index
public static bool Index(Analyzer analyzer, FileIndexSet fileIndex,IndexerSet indexer, bool create)
{
try
{
IndexWriter writer = new IndexWriter(fileIndex.Path, analyzer, create);
writer.SetMaxFieldLength(indexer.MaxFieldLength);
writer.SetRAMBufferSizeMB(indexer.RamBufferSize);
writer.SetMergeFactor(indexer.MergeFactor);
writer.SetMaxBufferedDocs(indexer.MaxBufferedDocs);
foreach (string dir in fileIndex.BaseDirs)
{
IndexDir(writer, dir);
}
return true;
}
catch (Exception )
{
return false;
}
}
示例5: CreateIndexWriter
/// <summary> Close the IndexReader and open an IndexWriter.</summary>
/// <throws> IOException </throws>
protected internal virtual void CreateIndexWriter()
{
if (indexWriter == null)
{
if (indexReader != null)
{
indexReader.Close();
indexReader = null;
}
indexWriter = new IndexWriter(directory, analyzer, false);
indexWriter.SetInfoStream(infoStream);
indexWriter.SetUseCompoundFile(useCompoundFile);
indexWriter.SetMaxBufferedDocs(maxBufferedDocs);
indexWriter.SetMaxFieldLength(maxFieldLength);
indexWriter.SetMergeFactor(mergeFactor);
}
}
示例6: CreateIndexWriter
/// <summary> Close the IndexReader and open an IndexWriter.</summary>
/// <throws> CorruptIndexException if the index is corrupt </throws>
/// <throws> LockObtainFailedException if another writer </throws>
/// <summary> has this index open (<code>write.lock</code> could not
/// be obtained)
/// </summary>
/// <throws> IOException if there is a low-level IO error </throws>
protected internal virtual void CreateIndexWriter()
{
if (indexWriter == null)
{
if (indexReader != null)
{
indexReader.Close();
indexReader = null;
}
indexWriter = new IndexWriter(directory, analyzer, false);
// IndexModifier cannot use ConcurrentMergeScheduler
// because it synchronizes on the directory which can
// cause deadlock
indexWriter.SetMergeScheduler(new SerialMergeScheduler());
indexWriter.SetInfoStream(infoStream);
indexWriter.SetUseCompoundFile(useCompoundFile);
if (maxBufferedDocs != IndexWriter.DISABLE_AUTO_FLUSH)
indexWriter.SetMaxBufferedDocs(maxBufferedDocs);
indexWriter.SetMaxFieldLength(maxFieldLength);
indexWriter.SetMergeFactor(mergeFactor);
}
}
示例7: IndexFile
public static bool IndexFile(bool create, IndexCompletedEventHandler OnIndexCompleted, IndexProgressChangedEventHandler OnProgressChanged)
{
try
{
if (create)
{
SupportClass.FileUtil.DeleteFolder(fileSet.Path);
}
IndexWriter writer = new IndexWriter(fileSet.Path, analyzer, create);
writer.SetMaxFieldLength(indexerSet.MaxFieldLength);
writer.SetRAMBufferSizeMB(indexerSet.RamBufferSize);
writer.SetMergeFactor(indexerSet.MergeFactor);
writer.SetMaxBufferedDocs(indexerSet.MaxBufferedDocs);
int i=0;
foreach (string dir in fileSet.BaseDirs)
{
i++;
FileIndexer.IndexDir(writer, dir,OnProgressChanged);
OnProgressChanged("IndexUtil", new IndexProgressChangedEventArgs(fileSet.BaseDirs.Count, i));
}
writer.Optimize();
writer.Close();
OnIndexCompleted("IndexUtil", new IndexCompletedEventArgs("File"));
return true;
}
catch (Exception e)
{
throw e;
}
}