X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fmix%2Ftasks%2Fpleroma%2Fsearch.ex;h=67aba79db7583eee3b266e19d6127bb736ebf017;hb=a9c82b62f2b73a79613bb23c3153ccf015733c52;hp=64396b92fe792f51e38b1e3494755520e97994da;hpb=6bb19454fddb6986de2169d90758d104eb069e2a;p=akkoma diff --git a/lib/mix/tasks/pleroma/search.ex b/lib/mix/tasks/pleroma/search.ex index 64396b92f..67aba79db 100644 --- a/lib/mix/tasks/pleroma/search.ex +++ b/lib/mix/tasks/pleroma/search.ex @@ -5,51 +5,19 @@ defmodule Mix.Tasks.Pleroma.Search do use Mix.Task import Mix.Pleroma - import Ecto.Query - alias Pleroma.Activity - alias Pleroma.Pagination - alias Pleroma.User @shortdoc "Manages elasticsearch" def run(["import", "activities" | _rest]) do start_pleroma() - - from(a in Activity, where: not ilike(a.actor, "%/relay")) - |> where([a], fragment("(? ->> 'type'::text) = 'Create'", a.data)) - |> Activity.with_preloaded_object() - |> Activity.with_preloaded_user_actor() - |> get_all(:activities) - end - - def run(["import", "users" | _rest]) do - start_pleroma() - - from(u in User, where: not ilike(u.ap_id, "%/relay")) - |> get_all(:users) - end - - defp get_all(query, index, max_id \\ nil) do - params = %{limit: 2000} - - 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(index) - - get_all(query, index, List.last(res).id) - end + IO.inspect(Pleroma.Config.get([Pleroma.Search.Elasticsearch.Cluster, :indexes, :activities])) + + IO.inspect( + Elasticsearch.Index.Bulk.upload( + Pleroma.Search.Elasticsearch.Cluster, + "activities", + Pleroma.Config.get([Pleroma.Search.Elasticsearch.Cluster, :indexes, :activities]) + ) + ) end end