Merge remote-tracking branch 'upstream/develop' into develop
[akkoma] / lib / pleroma / search / elasticsearch / hashtag_parser.ex
1 defmodule Pleroma.Search.Elasticsearch.Parsers.Hashtag do
2 defp to_es(term) when is_binary(term) do
3 %{
4 term: %{
5 hashtag: %{
6 value: String.downcase(term)
7 }
8 }
9 }
10 end
11
12 defp to_es({:quoted, term}), do: to_es(term)
13
14 defp to_es({:filter, ["hashtag", query]}) do
15 %{
16 term: %{
17 hashtag: %{
18 value: String.downcase(query)
19 }
20 }
21 }
22 end
23
24 defp to_es({:filter, _}), do: nil
25
26 def parse(q) do
27 Enum.map(q, &to_es/1)
28 |> Enum.filter(fn x -> x != nil end)
29 end
30 end