mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-02-01 03:46:44 +01:00
Partial revert of 6ef5354
(parallel reindex op)
This commit is contained in:
parent
b4f86ff2db
commit
f2fb46805a
1 changed files with 13 additions and 17 deletions
|
@ -203,25 +203,21 @@ defmodule PhilomenaQuery.Search do
|
||||||
def reindex(queryable, module, opts \\ []) do
|
def reindex(queryable, module, opts \\ []) do
|
||||||
index = @policy.index_for(module)
|
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
|
queryable
|
||||||
|> Batch.record_batches(opts)
|
|> Batch.record_batches(opts)
|
||||||
|> Task.async_stream(process, ordered: false, timeout: :infinity)
|
|> Enum.each(fn records ->
|
||||||
|> Stream.run()
|
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
|
end
|
||||||
|
|
||||||
@doc ~S"""
|
@doc ~S"""
|
||||||
|
|
Loading…
Reference in a new issue