X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fmix%2Ftasks%2Fpleroma%2Fsearch.ex;h=102bc5b63bed69fd7fcdd0b73c2e038948ed3687;hb=5624366056b026b17439756a3057676308e7f7d9;hp=9e0f376c38957a2c3042fb15b45196b9edabb07e;hpb=ed3a866f94e8912ee7974c203a5333fb7e6c04ee;p=akkoma diff --git a/lib/mix/tasks/pleroma/search.ex b/lib/mix/tasks/pleroma/search.ex index 9e0f376c3..102bc5b63 100644 --- a/lib/mix/tasks/pleroma/search.ex +++ b/lib/mix/tasks/pleroma/search.ex @@ -5,42 +5,16 @@ defmodule Mix.Tasks.Pleroma.Search do use Mix.Task import Mix.Pleroma - import Ecto.Query - alias Pleroma.Activity - alias Pleroma.Pagination @shortdoc "Manages elasticsearch" - def run(["import" | _rest]) do + def run(["import", "activities" | _rest]) do start_pleroma() - from(a in Activity, where: not ilike(a.actor, "%/relay")) - |> Activity.with_preloaded_object() - |> Activity.with_preloaded_user_actor() - |> get_all - end - - defp get_all(query, max_id \\ nil) do - params = %{limit: 20} - - params = - if max_id == nil do - params - else - Map.put(params, :max_id, max_id) - end - - res = - query - |> Pagination.fetch_paginated(params) - - if res == [] do - :ok - else - res - |> Pleroma.Elasticsearch.bulk_post(:activities) - - get_all(query, List.last(res).id) - end + Elasticsearch.Index.Bulk.upload( + Pleroma.Search.Elasticsearch.Cluster, + "activities", + Pleroma.Config.get([Pleroma.Search.Elasticsearch.Cluster, :indexes, :activities]) + ) end end