You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lucenenet.apache.org by "Lingam, ChandraMohan J" <ch...@intel.com> on 2012/02/10 21:42:06 UTC

[Lucene.Net] Lucene.Net 2.9.4 - Compound File and Multi File Behavior

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();
        }



[Lucene.Net] RE: Lucene.Net 2.9.4 - Compound File and Multi File Behavior

Posted by Jean-François Beaulac <JB...@versacom.ca>.
Maybe that can explain:

http://lucene.472066.n3.nabble.com/Compound-file-don-t-work-with-lucene-3-3-or-3-4-td3522215.html

jf


-----Message d'origine-----
De : Lingam, ChandraMohan J [mailto:chandramohan.j.lingam@intel.com] 
Envoyé : Friday, February 10, 2012 3:42 PM
À : lucene-net-user@lucene.apache.org
Objet : [Lucene.Net] Lucene.Net 2.9.4 - Compound File and Multi File Behavior

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();
        }