From f2fb46805a55e91c57530b04fd7abf536da40dd5 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 19 Dec 2024 15:39:51 -0500 Subject: [PATCH] Partial revert of 6ef5354 (parallel reindex op) --- lib/philomena_query/search.ex | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/lib/philomena_query/search.ex b/lib/philomena_query/search.ex index cb249d5e..cd02137c 100644 --- a/lib/philomena_query/search.ex +++ b/lib/philomena_query/search.ex @@ -203,25 +203,21 @@ defmodule PhilomenaQuery.Search do def reindex(queryable, module, opts \\ []) do index = @policy.index_for(module) - process = - fn records -> - lines = - Enum.flat_map(records, fn record -> - doc = index.as_json(record) - - [ - %{index: %{_index: index.index_name(), _id: doc.id}}, - doc - ] - end) - - Api.bulk(@policy.opensearch_url(), lines) - end - queryable |> Batch.record_batches(opts) - |> Task.async_stream(process, ordered: false, timeout: :infinity) - |> Stream.run() + |> Enum.each(fn records -> + lines = + Enum.flat_map(records, fn record -> + doc = index.as_json(record) + + [ + %{index: %{_index: index.index_name(), _id: doc.id}}, + doc + ] + end) + + Api.bulk(@policy.opensearch_url(), lines) + end) end @doc ~S"""