I am noticing a behavior where the index is automatically switched to
multi-file format from compound file format.
It is easy to reproduce on my system.
Basic Steps:
1. Create an index (default behavior: created as Compound format)
2. Update the index (after update, Lucene changed index format from Compound
to Multi-File)
Sample code attached. After running for the first time, change the create flag
to false and rerun in update mode.
Is this normal behavior? I thought Lucene honors the format unless explicitly
requested to change. I do not see this behavior in Lucene.Net 2.0 version and
can observe in 2.9.4 version.
Thanks!
Chandra
public void CreateDemoIndex()
{
Directory dir = FSDirectory.Open(new
System.IO.DirectoryInfo(@"C:\\temp\lucene101index"));
IndexWriter w = new IndexWriter(dir
, new
Lucene.Net.Analysis.Standard.StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29)
, true
, IndexWriter.MaxFieldLength.UNLIMITED);
List<Document> docList = new List<Document>();
Document doc = new Document();
doc.Add(new Field("animal", "CAT",
Field.Store.YES, Field.Index.ANALYZED_NO_NORMS));
doc.Add(new Field("says", "meow",
Field.Store.YES, Field.Index.ANALYZED_NO_NORMS));
docList.Add(doc);
doc = new Document();
doc.Add(new Field("animal", "DOG",
Field.Store.YES, Field.Index.ANALYZED_NO_NORMS));
doc.Add(new Field("says", "woof woof",
Field.Store.YES, Field.Index.ANALYZED_NO_NORMS));
docList.Add(doc);
doc = new Document();
doc.Add(new Field("animal", "pig",
Field.Store.YES, Field.Index.ANALYZED_NO_NORMS));
doc.Add(new Field("says", "oink oink",
Field.Store.YES, Field.Index.ANALYZED_NO_NORMS));
docList.Add(doc);
foreach (Document docInst in docList)
{
w.AddDocument(docInst);
}
w.Optimize();
Console.WriteLine("Number of documents in the index: {0}",
w.MaxDoc());
w.Close();
dir.Close();
}