You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lucenenet.apache.org by Dave <da...@yahoo.com> on 2007/05/14 01:29:37 UTC

IndexModifier and AddIndexes

Hi, I'm new to this list and have been working with
Lucene v1.9 for the past month. I have a single
question to ask, which can be found at the end of this
email. What follows is a bit of background on why I'm
asking. 
I've been learning how to increase the speed of
indexing by utilizing RAMDirectories and
multithreading. I originally was using an IndexReader
and IndexWriter and was going from one to the other as
the need required. As I read up on the documentation I
found it was much easier to use a IndexModifier as it
takes care of a lot of the background work. The only
problem is combining the indexes from the multiple
threads into a single FSDirectory index. Using an
indexWriter it is simple to call the AddIndexes
method, but since indexModifier does not have this
method I've needed to do some extra work to accomplish
the same thing.

The Question: Why is the method AddIndexes not a part
of indexModifier?

Thanks ahead of time,
Dave Gosinski


 
____________________________________________________________________________________
Finding fabulous fares is fun.  
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel bargains.
http://farechase.yahoo.com/promo-generic-14795097

unsubscribe

Posted by "Kainth, Sachin" <Sa...@atkinsglobal.com>.
unsubscribe


This email and any attached files are confidential and copyright protected. If you are not the addressee, any dissemination of this communication is strictly prohibited. Unless otherwise expressly agreed in writing, nothing stated in this communication shall be legally binding.

The ultimate parent company of the Atkins Group is WS Atkins plc.  Registered in England No. 1885586.  Registered Office Woodcote Grove, Ashley Road, Epsom, Surrey KT18 5BW.

Consider the environment. Please don't print this e-mail unless you really need to. 

RE: IndexModifier and AddIndexes

Posted by Digy <di...@gmail.com>.
Hi Dave & George,

According to
helppage(http://lucene.apache.org/java/1_9_0/api/org/apache/lucene/index/Ind
exModifier.html)
".... This class hides IndexReader and IndexWriter so that you do not need
to care about implementation details such as that adding documents is done
via IndexWriter and deletion is done via IndexReader.
.... Not all methods of IndexReader and IndexWriter are offered by this
class. If you need access to additional methods, either use those classes
directly or implement your own class that extends IndexModifier."

So I think it is not a deliberate desicion of the Author not to implement
"AddIndexes". 


Coding a class like below can be a solution. 

	  public class MyIndexModifier : IndexModifier
        {
            public MyIndexModifier(Lucene.Net.Store.Directory directory,
Analyzer analyzer, bool create)
                : base(directory, analyzer, create)
            {
            }

            public MyIndexModifier(System.IO.FileInfo file, Analyzer
analyzer, bool create)
                : base(file, analyzer, create)
            {
            }

            public MyIndexModifier(String dirName, Analyzer analyzer, bool
create)
                : base(dirName, analyzer, create)
            {
            }

            public void AddIndexes(IndexReader[] readers)
            {
                base.AssureOpen();
                base.CreateIndexWriter();
                base.indexWriter.AddIndexes(readers);
            }

            public void AddIndexes(Lucene.Net.Store.Directory[] dirs)
            {
                base.AssureOpen();
                base.CreateIndexWriter();
                base.indexWriter.AddIndexes(dirs);
            }
        }


But I think, it would be better to add that method to the IndexModifier
***********************************
Index: IndexModifier.cs
===================================================================
--- IndexModifier.cs	(revision 536611)
+++ IndexModifier.cs	(working copy)
@@ -575,5 +575,19 @@
 		System.out.println(indexModifier.docCount() + " docs in
index");
 		indexModifier.close();
 		}*/
+
+        public void AddIndexes(IndexReader[] readers)
+        {
+            AssureOpen();
+            CreateIndexWriter();
+            indexWriter.AddIndexes(readers);
+        }
+
+        public void AddIndexes(Lucene.Net.Store.Directory[] dirs)
+        {
+            AssureOpen();
+            CreateIndexWriter();
+            indexWriter.AddIndexes(dirs);
+        }
 	}
 }
\ No newline at end of file
***********************************



DIGY




-----Original Message-----
From: Dave [mailto:dave.gosinski@yahoo.com] 
Sent: Monday, May 14, 2007 2:30 AM
To: lucene-net-user@incubator.apache.org
Subject: IndexModifier and AddIndexes

Hi, I'm new to this list and have been working with
Lucene v1.9 for the past month. I have a single
question to ask, which can be found at the end of this
email. What follows is a bit of background on why I'm
asking. 
I've been learning how to increase the speed of
indexing by utilizing RAMDirectories and
multithreading. I originally was using an IndexReader
and IndexWriter and was going from one to the other as
the need required. As I read up on the documentation I
found it was much easier to use a IndexModifier as it
takes care of a lot of the background work. The only
problem is combining the indexes from the multiple
threads into a single FSDirectory index. Using an
indexWriter it is simple to call the AddIndexes
method, but since indexModifier does not have this
method I've needed to do some extra work to accomplish
the same thing.

The Question: Why is the method AddIndexes not a part
of indexModifier?

Thanks ahead of time,
Dave Gosinski


 
____________________________________________________________________________
________
Finding fabulous fares is fun.  
Let Yahoo! FareChase search your favorite travel sites to find flight and
hotel bargains.
http://farechase.yahoo.com/promo-generic-14795097