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.Meilisearch do
14 endpoint = Pleroma.Config.get([Pleroma.Search.Meilisearch, :url])
18 "#{endpoint}/indexes/objects/settings/ranking-rules",
30 Pleroma.Repo.chunk_stream(
32 where: fragment("data->>'type' = 'Note'") and fragment("LENGTH(data->>'source') > 0")
37 |> Stream.map(fn objects ->
38 Enum.map(objects, fn object ->
40 %{id: object.id, source: data["source"], ap: data["id"]}
43 |> Stream.each(fn objects ->
46 "#{endpoint}/indexes/objects/documents",
47 Jason.encode!(objects)
50 IO.puts("Indexed #{Enum.count(objects)} entries")