Skip to content

Commit

Permalink
Merge remote-tracking branch 'philo/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Meow committed Dec 19, 2024
2 parents 6346c5f + f2fb468 commit baa7ad3
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions lib/philomena_query/search.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit baa7ad3

Please sign in to comment.