Use a genserver to periodically fetch metrics
[akkoma] / lib / pleroma / search / elasticsearch / activity_parser.ex
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
4
5 defmodule Pleroma.Search.Elasticsearch.Parsers.Activity do
6 defp to_es(term) when is_binary(term) do
7 %{
8 match: %{
9 content: %{
10 query: term,
11 operator: "AND"
12 }
13 }
14 }
15 end
16
17 defp to_es({:quoted, term}), do: to_es(term)
18
19 defp to_es({:filter, ["hashtag", query]}) do
20 %{
21 term: %{
22 hashtags: %{
23 value: query
24 }
25 }
26 }
27 end
28
29 defp to_es({:filter, [field, query]}) do
30 %{
31 term: %{
32 field => %{
33 value: query
34 }
35 }
36 }
37 end
38
39 def parse(q) do
40 [
41 %{
42 exists: %{
43 field: "content"
44 }
45 }
46 ] ++
47 Enum.map(q, &to_es/1)
48 end
49 end