Commit 5627ea21 authored by Matija Obreza's avatar Matija Obreza
Browse files

Use scrollable result to reindex ES instead of paginated queries

parent 2d846a15
......@@ -46,9 +46,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.core.task.TaskExecutor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.elasticsearch.core.query.IndexQuery;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
......@@ -151,34 +148,14 @@ public class AdminController {
AppliedFilters filters = mapper.readValue(jsonFilter, AppliedFilters.class);
int page = 0, size = 100;
List<IndexQuery> queries = new ArrayList<IndexQuery>();
do {
LOG.info("Reindexing progress " + (page * size));
queries.clear();
Page<Accession> accessions = filterService.listAccessions(filters, new PageRequest(page, size));
if (!accessions.hasContent()) {
LOG.info("No more content");
break;
}
page++;
for (Accession a : accessions) {
elasticUpdater.update(Accession.class, a.getId());
}
genesysLowlevelRepository.listAccessionIds(filters, null, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
long accessionId = rs.getLong(1);
if (slow) {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
break;
}
elasticUpdater.update(Accession.class, accessionId);
}
} while (true);
});
LOG.info("Done.");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment