1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Mix.Tasks.Pleroma.Search do
10 alias Pleroma.Pagination
12 @shortdoc "Manages elasticsearch"
14 def run(["import" | _rest]) do
17 from(a in Activity, where: not ilike(a.actor, "%/relay"))
18 |> Activity.with_preloaded_object()
19 |> Activity.with_preloaded_user_actor()
23 defp get_all(query, max_id \\ nil) do
30 Map.put(params, :max_id, max_id)
35 |> Pagination.fetch_paginated(params)
41 |> Pleroma.Elasticsearch.bulk_post(:activities)
43 get_all(query, List.last(res).id)