Index: src/test/org/apache/lucene/index/TestCheckIndex.java =================================================================== --- src/test/org/apache/lucene/index/TestCheckIndex.java (revision 614566) +++ src/test/org/apache/lucene/index/TestCheckIndex.java (working copy) @@ -20,6 +20,8 @@ import java.io.IOException; import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import java.util.List; +import java.util.ArrayList; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.store.MockRAMDirectory; @@ -46,6 +48,9 @@ ByteArrayOutputStream bos = new ByteArrayOutputStream(1024); CheckIndex.out = new PrintStream(bos); - assertTrue(CheckIndex.check(dir, false)); + assertTrue(CheckIndex.check(dir, false, null)); + final List onlySegments = new ArrayList(); + onlySegments.add("_0"); + assertTrue(CheckIndex.check(dir, false, onlySegments)); } } Index: src/java/org/apache/lucene/index/CheckIndex.java =================================================================== --- src/java/org/apache/lucene/index/CheckIndex.java (revision 614566) +++ src/java/org/apache/lucene/index/CheckIndex.java (working copy) @@ -27,6 +27,8 @@ import java.io.IOException; import java.util.Collection; import java.util.Iterator; +import java.util.List; +import java.util.ArrayList; /** * Basic tool to check the health of an index and write a @@ -61,7 +63,7 @@ } /** Returns true if index is clean, else false.*/ - public static boolean check(Directory dir, boolean doFix) throws IOException { + public static boolean check(Directory dir, boolean doFix, List onlySegments) throws IOException { NumberFormat nf = NumberFormat.getInstance(); SegmentInfos sis = new SegmentInfos(); @@ -115,6 +117,15 @@ out.println("Segments file=" + segmentsFileName + " numSegments=" + numSegments + " version=" + sFormat); + if (onlySegments != null) { + out.print("\nChecking only these segments:"); + Iterator it = onlySegments.iterator(); + while (it.hasNext()) { + out.print(" " + it.next()); + } + out.println(":"); + } + if (skip) { out.println("\nERROR: this index appears to be created by a newer version of Lucene than this tool was compiled on; please re-compile this tool on the matching version of Lucene; exiting"); return false; @@ -127,6 +138,8 @@ int numBadSegments = 0; for(int i=0;i