1 defmodule Pleroma.Search.Elasticsearch do
2 @behaviour Pleroma.Search
4 alias Pleroma.Web.MastodonAPI.StatusView
6 defp to_es(term) when is_binary(term) do
17 defp to_es({:quoted, term}), do: to_es(term)
19 defp to_es({:filter, ["hashtag", query]}) do
29 defp to_es({:filter, [field, query]}) do
41 |> SearchParser.parse!()
46 def search(%{assigns: %{user: user}} = _conn, %{q: query} = _params, _options) do
55 out = Pleroma.Elasticsearch.search_activities(q)
57 with {:ok, raw_results} <- out do
60 |> Map.get(:body, %{})
61 |> Map.get("hits", %{})
62 |> Map.get("hits", [])
63 |> Enum.map(fn result -> result["_id"] end)
64 |> Pleroma.Activity.all_by_ids_with_object()
70 StatusView.render("index.json",