From 70235c883d2af5bb6e597b672f493d6d673e7b59 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 11 Feb 2019 12:11:10 -0500 Subject: [PATCH] Indexer orders by ID for batch consistency Signed-off-by: Bill Erickson --- Open-ILS/src/perlmods/lib/OpenILS/Elastic/BibSearch.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Elastic/BibSearch.pm b/Open-ILS/src/perlmods/lib/OpenILS/Elastic/BibSearch.pm index 86abb412a6..b9a7e1f390 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Elastic/BibSearch.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Elastic/BibSearch.pm @@ -218,22 +218,26 @@ sub get_bib_ids { my $stop_id = $state->{stop_record}; # TODO my $start_date = $state->{start_date}; - my ($select, $from, $where, $order); + my ($select, $from, $where); if ($start_date) { $select = "SELECT id"; $from = "FROM elastic.bib_last_mod_date"; $where = "WHERE last_mod_date > '$start_date'"; - $order = "ORDER BY last_mod_date"; } else { $select = "SELECT id"; $from = "FROM biblio.record_entry"; $where = "WHERE NOT deleted AND active"; - $order = "ORDER BY edit_date, id"; } $where .= " AND id >= $start_id" if $start_id; $where .= " AND id <= $stop_id" if $stop_id; + # Ordering by ID is the simplest way to guarantee all requested + # records are processed, given that edit dates may not be unique + # and that we're using start_id/stop_id instead of OFFSET to + # define the batches. + my $order = "ORDER BY id"; + my $sql = "$select $from $where $order LIMIT $BIB_BATCH_SIZE"; my $ids = $self->get_db_rows($sql); -- 2.11.0