By the way
> Hi, one thing that always works to "forcefully" upgrade without reindexing. 
> You
> just merge the old index into a completely new index not by coping files, but 
> by
> sending their SegmentReaders to addIndex, stripping all metadata from them
> with some trick:
> https://lucene.apache.org/core/8_11_0/core/org/apache/lucene/index/SlowCo
> decReaderWrapper.html in combination with
> <https://lucene.apache.org/core/8_11_0/core/org/apache/lucene/index/Index
> Writer.html#addIndexes-org.apache.lucene.index.CodecReader...->
> 
> One way to do this is the following:
> - Open old index using DirectoryReader.open(): reader =
> DirectoryReader.open(...old directory...)
> - Create a new Index with IndexWriter writer: writer = new IndedxWriter(...new
> directory...)
> - Call
> writer.addIndexes(reader.leaves().stream().map(IndexReaderContext::reader).
> map(SlowCodecReaderWrapper::wrap).toArray(CodecReader[]::new));

This trick also works if you want to transform indexes. I wrote some code that 
on the-fly rewrites old NumericField to PointField. The trick is to add another 
FilterLeafReader (before wrapping with SlowCodecReaderWrapper), that detects 
legacy numeric fields, removes them fromm metadata and feeds them as new stream 
of flat BKD points enumerated by the TermsEnum (which works because order is 
same and hierarchy is generated by the receiving IndexWriter) to a new field 
with PointField metadata. This is a bit hacky but works great.

Uwe


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to