Re: Check to see if index is optimized
Based on the method sent earlier, it looks like Lucene first checks to see if optimization is even necessary. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Check to see if index is optimized
> If an index has no deletions, it does not need to be optimized. You can > find out if it has deletions with IndexReader.hasDeletions. Is that true? An index that has just been created (with no deletions) can still have multiple segments that could be optimized. I'm not sure your statement is correct. -Mike On Fri, 07 Jan 2005 14:22:23 -0600, Luke Francl <[EMAIL PROTECTED]> wrote: > On Fri, 2005-01-07 at 13:24, Crump, Michael wrote: > > > Is there a simple way to check and see if an index is already optimized? > > What happens if optimize is called on an already optimized index - does > > the call basically do a noop? Or is it still and expensive call? > > If an index has no deletions, it does not need to be optimized. You can > find out if it has deletions with IndexReader.hasDeletions. > > I am not sure what the cost of optimization is if the index doesn't need > it. Perhaps someone else on this list knows. > > Regards, > Luke Francl > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Check to see if index is optimized
On Fri, 2005-01-07 at 13:24, Crump, Michael wrote: > Is there a simple way to check and see if an index is already optimized? > What happens if optimize is called on an already optimized index - does > the call basically do a noop? Or is it still and expensive call? If an index has no deletions, it does not need to be optimized. You can find out if it has deletions with IndexReader.hasDeletions. I am not sure what the cost of optimization is if the index doesn't need it. Perhaps someone else on this list knows. Regards, Luke Francl - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Check to see if index is optimized
Crump, Michael writes: > > Is there a simple way to check and see if an index is already optimized? > What happens if optimize is called on an already optimized index - does > the call basically do a noop? Or is it still and expensive call? > Why don't you just try that? E.g. using luke. Or three lines of code... You will find, that calling optimize for an optimized index does not change the index. (optimized means just one segement and no deleted documents) So I guess the answer for your first question can be found in the sources of optimize: public synchronized void optimize() throws IOException { flushRamSegments(); while (segmentInfos.size() > 1 || (segmentInfos.size() == 1 && (SegmentReader.hasDeletions(segmentInfos.info(0)) || segmentInfos.info(0).dir != directory || (useCompoundFile && (!SegmentReader.usesCompoundFile(segmentInfos.info(0)) || SegmentReader.hasSeparateNorms(segmentInfos.info(0))) { int minSegment = segmentInfos.size() - mergeFactor; mergeSegments(minSegment < 0 ? 0 : minSegment); } } segmentInfos is private in IndexWriter, so I suspect you cannot check that without modifying lucene. HTH Morus - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Check to see if index is optimized
This may not be a simple way, but you could just do a quick check on the folder to see if there is more than one file containing the name segment. Luke - Original Message - From: "Crump, Michael" <[EMAIL PROTECTED]> To: Sent: Friday, January 07, 2005 2:24 PM Subject: Check to see if index is optimized Hello, Lucene is great! I just have a question. Is there a simple way to check and see if an index is already optimized? What happens if optimize is called on an already optimized index - does the call basically do a noop? Or is it still and expensive call? Regards, Michael - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Check to see if index is optimized
Hello, Lucene is great! I just have a question. Is there a simple way to check and see if an index is already optimized? What happens if optimize is called on an already optimized index - does the call basically do a noop? Or is it still and expensive call? Regards, Michael