IndexReader.open() fails for all old pre-3.0 indexes in Lucene trunk. This is tested by TestBackwardCompatibility. On the other hand, IndexWriter's ctor does not fail on open an existing index, that contains an old segment, because it does not check preexisting segments. It only throws IndexFormatTooOldException, if you merge segments or open a getReader(). When ConcurrentMergeScheduler is used, this may happen in an foreign thread which makes it even worse.
Mike and me propose:
- In 3.x introduce a new segments file format when committing, that contains the oldest and newest version of the index segments (not sure which version number to take here), this file format has new version, so its easy to detect (DefaultSegmentsFileWriter/Reader)
- In trunk when opening IndexWriter check the following: If segments file is in new format, check minimum version from this file, if pre-3.0 throw IFTOE; if segments file is in old format (can be 3.0 or 3.x index not yet updated), try to open FieldsReader, as 2.9 indexes only can be detected using this - older indexes should fail before and never come to that place. If this succeeds, write a new segments file in new format (maybe after commit or whatever)