1 # Akkoma: A lightweight social networking server
2 # Copyright © 2022-2022 Akkoma Authors <https://git.ihatebeinga.live/IHBAGang/akkoma/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Search.Elasticsearch.Store do
6 @behaviour Elasticsearch.Store
7 alias Pleroma.Search.Elasticsearch.Cluster
18 def transaction(fun) do
19 {:ok, result} = Repo.transaction(fun, timeout: :infinity)
23 def search(_, _, _, :skip), do: []
25 def search(:raw, index, q) do
26 with {:ok, raw_results} <- Elasticsearch.post(Cluster, "/#{index}/_search", q) do
29 |> Map.get("hits", %{})
30 |> Map.get("hits", [])
40 def search(:activities, q) do
41 with {:ok, results} <- search(:raw, "activities", q) do
43 |> Enum.map(fn result -> result["_id"] end)
44 |> Pleroma.Activity.all_by_ids_with_object()
45 |> Enum.sort(&(&1.inserted_at >= &2.inserted_at))