Lucene IndexWriter.addIndexes does not merge indexes

1

My problem is this, I have a code that apparently is fine. What I try to do is join 2 indexes located in 2 folders. The code is as follows

    public static void addIndices(String indexPath, boolean create) throws IOException {
    Analyzer analyzer = new StandardAnalyzer();
    IndexWriterConfig iwc = new IndexWriterConfig(analyzer);
    if (create) {
        iwc.setOpenMode(OpenMode.CREATE);
    } else {
        iwc.setOpenMode(OpenMode.CREATE_OR_APPEND);
    }
    if (sources.size() > 1) {

        //Abrimos todos los directorios para acceder a los archivos segments
        Directory[] aux = new RAMDirectory[sources.size()-1];

        for(int i = 1; i < sources.size(); i++) {
            aux[i-1] = new RAMDirectory(FSDirectory.open(Paths.get(sources.get(i))), new IOContext());
        }
        IndexWriter writer = new IndexWriter(new RAMDirectory(FSDirectory.open(Paths.get(sources.get(0))), new IOContext()), iwc);

        writer.addIndexes(aux);
        writer.commit();
        writer.close();
    }

}

What happens is that the indexes of both folders are not combined.

    
asked by Brais Castiñeiras Galdo 17.03.2018 в 00:23
source

0 answers