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]