本文整理汇总了C#中Lucene.Net.Index.IndexWriter.SetUseCompoundFile方法的典型用法代码示例。如果您正苦于以下问题:C# IndexWriter.SetUseCompoundFile方法的具体用法?C# IndexWriter.SetUseCompoundFile怎么用?C# IndexWriter.SetUseCompoundFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Index.IndexWriter
的用法示例。
在下文中一共展示了IndexWriter.SetUseCompoundFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IndexFile
public void IndexFile(string filePath)
{
PropertyDescriptors descriptors = new PropertyDescriptors();
descriptors.LoadData(System.Windows.Forms.Application.StartupPath + "\\PropertyDescriptors.xml");
Analyzer a = new Lucene.Net.Analysis.Standard.StandardAnalyzer();
bool create = !(System.IO.Directory.Exists(_idxDir) && IndexReader.IndexExists(_idxDir));
IndexWriter iw = new IndexWriter(_idxDir, a, create);
iw.SetUseCompoundFile(true);
AdDataStream adStream = new AdDataStream(filePath);
adStream.LoadData();
foreach (Advert ad in adStream.FetchAd())
{
Document doc = new Document();
foreach (string s in ad.GetDictionary().Keys)
{
string temp = descriptors.GetIndexableFormat(descriptors[s], ad[s]);
doc.Add(Field.Text(s, temp));
}
iw.AddDocument(doc);
if (_updateCallback != null)
{
_updateCallback("Added Document: " + ad["Title"]);
}
}
iw.Optimize();
iw.Close();
}
示例2: MakeIndex
private Directory MakeIndex()
{
Directory dir = new RAMDirectory();
try
{
System.Random r = NewRandom();
Analyzer analyzer = new SimpleAnalyzer();
IndexWriter writer = new IndexWriter(dir, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
writer.SetUseCompoundFile(false);
for (int d = 1; d <= NUM_DOCS; d++)
{
Document doc = new Document();
for (int f = 1; f <= NUM_FIELDS; f++)
{
doc.Add(new Field("f" + f, data[f % data.Length] + '#' + data[r.Next(data.Length)], Field.Store.YES, Field.Index.ANALYZED));
}
writer.AddDocument(doc);
}
writer.Close();
}
catch (System.Exception e)
{
throw new System.SystemException("", e);
}
return dir;
}
示例3: MakeIndex
private static Directory MakeIndex()
{
Directory dir = new RAMDirectory();
try
{
System.Random r = new System.Random((System.Int32) (BASE_SEED + 42));
Analyzer analyzer = new SimpleAnalyzer();
IndexWriter writer = new IndexWriter(dir, analyzer, true);
writer.SetUseCompoundFile(false);
for (int d = 1; d <= NUM_DOCS; d++)
{
Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
for (int f = 1; f <= NUM_FIELDS; f++)
{
doc.Add(new Field("f" + f, data[f % data.Length] + '#' + data[r.Next(data.Length)], Field.Store.YES, Field.Index.TOKENIZED));
}
writer.AddDocument(doc);
}
writer.Close();
}
catch (System.Exception e)
{
throw new System.SystemException("", e);
}
return dir;
}
示例4: CreateIndex
public void CreateIndex(string databaseFileName)
{
IndexWriter writer = new IndexWriter(indexFolderName, new StandardAnalyzer(), true);
writer.SetUseCompoundFile(false);
IndexDatabase(writer, Container.GetContainer(databaseFileName));
writer.Optimize();
writer.Close();
}
示例5: GetAzureIndexWriter
public static IndexWriter GetAzureIndexWriter(this LuceneIndexer indexer)
{
indexer.EnsureIndex(false);
var writer = new IndexWriter(indexer.GetLuceneDirectory(), indexer.IndexingAnalyzer, false, IndexWriter.MaxFieldLength.UNLIMITED);
writer.SetRAMBufferSizeMB(10.0);
writer.SetUseCompoundFile(false);
writer.SetMaxMergeDocs(10000);
writer.SetMergeFactor(100);
return writer;
}
示例6: SetUp
public override void SetUp()
{
base.SetUp();
fieldInfos = new FieldInfos();
DocHelper.SetupDoc(testDoc);
fieldInfos.Add(testDoc);
IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true);
writer.SetUseCompoundFile(false);
writer.AddDocument(testDoc);
writer.Close();
segmentName = writer.NewestSegment().name;
}
示例7: DoTest
private void DoTest(System.IO.StringWriter out_Renamed, bool useCompoundFiles)
{
Directory directory = new RAMDirectory();
Analyzer analyzer = new SimpleAnalyzer();
IndexWriter writer = new IndexWriter(directory, analyzer, true);
writer.SetUseCompoundFile(useCompoundFiles);
int MAX_DOCS = 225;
for (int j = 0; j < MAX_DOCS; j++)
{
Document d = new Document();
d.Add(Field.Text(PRIORITY_FIELD, HIGH_PRIORITY));
d.Add(Field.Text(ID_FIELD, System.Convert.ToString(j)));
writer.AddDocument(d);
}
writer.Close();
// try a search without OR
Searcher searcher = new IndexSearcher(directory);
Hits hits = null;
QueryParsers.QueryParser parser = new QueryParsers.QueryParser(PRIORITY_FIELD, analyzer);
Query query = parser.Parse(HIGH_PRIORITY);
out_Renamed.WriteLine("Query: " + query.ToString(PRIORITY_FIELD));
hits = searcher.Search(query);
PrintHits(out_Renamed, hits);
CheckHits(hits, MAX_DOCS);
searcher.Close();
// try a new search with OR
searcher = new IndexSearcher(directory);
hits = null;
parser = new QueryParsers.QueryParser(PRIORITY_FIELD, analyzer);
query = parser.Parse(HIGH_PRIORITY + " OR " + MED_PRIORITY);
out_Renamed.WriteLine("Query: " + query.ToString(PRIORITY_FIELD));
hits = searcher.Search(query);
PrintHits(out_Renamed, hits);
CheckHits(hits, MAX_DOCS);
searcher.Close();
}
示例8: Main
static void Main()
{
_indexWriter = new IndexWriter(FSDirectory.Open(new DirectoryInfo(_indexPath)), new StandardAnalyzer(), true,
IndexWriter.MaxFieldLength.UNLIMITED);
_indexWriter.SetUseCompoundFile(false);
// TODO: we can do this in batches, and trigger another thread to do that
var sw = ParseDisks(disk => disks.Add(disk));
Console.WriteLine("Elapsed: " + sw.Elapsed);
sw.Restart();
foreach (var disk in disks)
{
AddDocShortVersion(disk);
}
_indexWriter.SetUseCompoundFile(true);
_indexWriter.Optimize();
_indexWriter.Close(true);
Console.WriteLine("Elapsed: " + sw.Elapsed);
}
示例9: Indexer
/// <summary>
/// Constructor
/// </summary>
/// <param name="indexPath">Path where you wish to create the index</param>
/// <param name="mode">One of Create, Append or Search</param>
public Indexer(string indexPath, IndexMode mode)
{
m_indexMode = mode;
m_bSucess = false;
m_analyzer = new StandardAnalyzer();
if (mode == IndexMode.CREATE)
{
try
{
m_indexWriter = new IndexWriter(indexPath, m_analyzer, true);
m_indexWriter.SetUseCompoundFile(true);
m_bSucess = true;
}
catch (Exception e)
{
Logger.Instance.LogException(e);
m_bSucess = false;
}
}
else if (mode == IndexMode.APPEND)
{
try
{
m_indexWriter = new IndexWriter(indexPath, m_analyzer, false);
m_indexWriter.SetUseCompoundFile(true);
m_bSucess = true;
}
catch (Exception e)
{
Logger.Instance.LogException(e);
m_bSucess = false;
}
}
else if (mode == IndexMode.SEARCH)
{
try
{
m_indexSearcher = new IndexSearcher(indexPath);
m_bSucess = true;
}
catch (Exception e)
{
Logger.Instance.LogException(e);
m_bSucess = false;
}
}
}
示例10: button1_Click
private void button1_Click(object sender, EventArgs e)
{
//FilterData.PrepareCharMap();
int total = this.databaseDataSet.trans.Count;
int counter = 1;
string fsPath = indexpath;
if (!System.IO.Directory.Exists(fsPath)) System.IO.Directory.CreateDirectory(fsPath);
if (IndexReader.IndexExists(fsPath)) return;
RAMDirectory dir = new RAMDirectory();
IndexWriter ramWriter = new IndexWriter(dir, new DiacriticAnalyzer(FilterData.stopWords), true);
IndexWriter fsWriter = new IndexWriter(fsPath, new DiacriticAnalyzer(FilterData.stopWords), !IndexReader.IndexExists(fsPath));
ramWriter.SetUseCompoundFile(false);
fsWriter.SetUseCompoundFile(false);
foreach (DataRow row in this.databaseDataSet.trans.Rows)
{
Document doc = new Document();
string pid = row[this.databaseDataSet.trans.pidColumn].ToString();
string sid = row[this.databaseDataSet.trans.sidColumn].ToString();
string ayatno = row[this.databaseDataSet.trans.ayatnoColumn].ToString();
string arabic = row[this.databaseDataSet.trans.ayat_arabicColumn].ToString();
string urdu = row[this.databaseDataSet.trans.ayat_urduColumn].ToString();
string english = row[this.databaseDataSet.trans.ayat_descColumn].ToString();
doc.Add(Field.Keyword("pid", pid));
doc.Add(Field.Keyword("sid", sid));
doc.Add(Field.Keyword("ayatno", ayatno));
doc.Add(Field.Text("ayat_desc", english));
doc.Add(Field.Text("ayat_arabic", arabic));
doc.Add(Field.Text("ayat_urdu", urdu));
doc.Add(Field.Text("contents", arabic + Environment.NewLine + urdu + Environment.NewLine + english));
ramWriter.AddDocument(doc);
int percent = counter * 100 / total;
this.progressBar1.Value = percent;
label1.Text = percent.ToString() + "%";
counter++;
Application.DoEvents();
}
ramWriter.Optimize();
fsWriter.AddIndexes(new Lucene.Net.Store.Directory[] { dir });
ramWriter.Close();
fsWriter.Close();
MessageBox.Show("Done Indexing!");
}
示例11: DoTestSearch
private void DoTestSearch(System.IO.StreamWriter out_Renamed, bool useCompoundFile)
{
Directory directory = new RAMDirectory();
Analyzer analyzer = new SimpleAnalyzer();
IndexWriter writer = new IndexWriter(directory, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
writer.SetUseCompoundFile(useCompoundFile);
System.String[] docs = new System.String[]{"a b c d e", "a b c d e a b c d e", "a b c d e f g h i j", "a c e", "e c a", "a c e a c e", "a c e a b c"};
for (int j = 0; j < docs.Length; j++)
{
Document d = new Document();
d.Add(new Field("contents", docs[j], Field.Store.YES, Field.Index.ANALYZED));
writer.AddDocument(d);
}
writer.Close();
Searcher searcher = new IndexSearcher(directory);
System.String[] queries = new System.String[]{"a b", "\"a b\"", "\"a b c\"", "a c", "\"a c\"", "\"a c e\""};
ScoreDoc[] hits = null;
QueryParser parser = new QueryParser("contents", analyzer);
parser.SetPhraseSlop(4);
for (int j = 0; j < queries.Length; j++)
{
Query query = parser.Parse(queries[j]);
out_Renamed.WriteLine("Query: " + query.ToString("contents"));
//DateFilter filter =
// new DateFilter("modified", Time(1997,0,1), Time(1998,0,1));
//DateFilter filter = DateFilter.Before("modified", Time(1997,00,01));
//System.out.println(filter);
hits = searcher.Search(query, null, 1000).scoreDocs;
out_Renamed.WriteLine(hits.Length + " total results");
for (int i = 0; i < hits.Length && i < 10; i++)
{
Document d = searcher.Doc(hits[i].doc);
out_Renamed.WriteLine(i + " " + hits[i].score + " " + d.Get("contents"));
}
}
searcher.Close();
}
示例12: TestIndexing
public virtual void TestIndexing()
{
Directory mainDir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(mainDir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
writer.SetUseCompoundFile(false);
IndexReader reader = writer.GetReader(); // start pooling readers
reader.Close();
writer.SetMergeFactor(2);
writer.SetMaxBufferedDocs(10);
RunThread[] indexThreads = new RunThread[4];
for (int x = 0; x < indexThreads.Length; x++)
{
indexThreads[x] = new RunThread(this, x % 2, writer);
indexThreads[x].Name = "Thread " + x;
indexThreads[x].Start();
}
long startTime = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond);
long duration = 5 * 1000;
while (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - startTime) < duration)
{
System.Threading.Thread.Sleep(new System.TimeSpan((System.Int64) 10000 * 100));
}
int delCount = 0;
int addCount = 0;
for (int x = 0; x < indexThreads.Length; x++)
{
indexThreads[x].run_Renamed_Field = false;
Assert.IsTrue(indexThreads[x].ex == null);
addCount += indexThreads[x].addCount;
delCount += indexThreads[x].delCount;
}
for (int x = 0; x < indexThreads.Length; x++)
{
indexThreads[x].Join();
}
//System.out.println("addCount:"+addCount);
//System.out.println("delCount:"+delCount);
writer.Close();
mainDir.Close();
}
示例13: IntranetIndexer
/// <summary>
/// Creates a new index in <c>directory</c>. Overwrites the existing index in that directory.
/// </summary>
/// <param name="directory">Path to index (will be created if not existing).</param>
public IntranetIndexer(string directory)
{
writer = new IndexWriter(directory, new StandardAnalyzer(), true);
writer.SetUseCompoundFile(true);
}
示例14: CreateIndex
private void CreateIndex(Directory dir)
{
IndexWriter iw = new IndexWriter(dir, anlzr, true, IndexWriter.MaxFieldLength.LIMITED);
iw.SetMaxBufferedDocs(5);
iw.SetMergeFactor(3);
iw.SetSimilarity(similarityOne);
iw.SetUseCompoundFile(true);
iw.Close();
}
示例15: AddDocs
private void AddDocs(Directory dir, int ndocs, bool compound)
{
IndexWriter iw = new IndexWriter(dir, anlzr, false, IndexWriter.MaxFieldLength.LIMITED);
iw.SetMaxBufferedDocs(5);
iw.SetMergeFactor(3);
iw.SetSimilarity(similarityOne);
iw.SetUseCompoundFile(compound);
for (int i = 0; i < ndocs; i++)
{
iw.AddDocument(NewDoc());
}
iw.Close();
}