From d9309a275e2a0a9c272aaf691e2389daa680a6e3 Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 11 Jan 2025 12:07:05 -0500 Subject: [PATCH] Use custom batch sizes tailored to each schema --- lib/philomena/search_indexer.ex | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/philomena/search_indexer.ex b/lib/philomena/search_indexer.ex index 0e0a0c83..32ed018b 100644 --- a/lib/philomena/search_indexer.ex +++ b/lib/philomena/search_indexer.ex @@ -40,6 +40,16 @@ defmodule Philomena.SearchIndexer do Tag => Tags } + @batch_sizes %{ + Comment => 2048, + Filter => 2048, + Gallery => 1024, + Image => 32, + Post => 2048, + Report => 128, + Tag => 2048 + } + @doc """ Recreate the index corresponding to all schemas, and then reindex all of the documents within. @@ -115,7 +125,7 @@ defmodule Philomena.SearchIndexer do # Reports currently require handling for their polymorphic nature Report |> preload([:user, :admin]) - |> Batch.record_batches() + |> Batch.record_batches(batch_size: @batch_sizes[Report]) |> Enum.each(fn records -> records |> Polymorphic.load_polymorphic(reportable: [reportable_id: :reportable_type]) @@ -129,6 +139,6 @@ defmodule Philomena.SearchIndexer do schema |> preload(^context.indexing_preloads()) - |> Search.reindex(schema) + |> Search.reindex(schema, batch_size: @batch_sizes[schema]) end end