Merge branch 'develop' of gitssh.ihatebeinga.live:IHBAGang/pleroma into develop
authorsadposter <hannah+pleroma@coffee-and-dreams.uk>
Tue, 14 Dec 2021 14:01:09 +0000 (14:01 +0000)
committersadposter <hannah+pleroma@coffee-and-dreams.uk>
Tue, 14 Dec 2021 14:01:09 +0000 (14:01 +0000)
1  2 
lib/pleroma/search/elasticsearch.ex

index 3815ef766db0f47a0059a984cf2b62a22b96d307,e770fe536da5be1f33965ea636413c2a62357f12..c897a2ace673beef9c5a7a74b0e02541573f6c98
@@@ -2,36 -2,36 +2,51 @@@ defmodule Pleroma.Search.Elasticsearch 
    @behaviour Pleroma.Search
  
    alias Pleroma.Web.MastodonAPI.StatusView
+   alias Pleroma.Web.MastodonAPI.AccountView
    alias Pleroma.Web.ActivityPub.Visibility
+   alias Pleroma.Search.Elasticsearch.Parsers
+   alias Pleroma.Web.Endpoint
  
-   defp to_es(term) when is_binary(term) do
+   defp es_query(:activity, query) do
      %{
-       match: %{
-         content: %{
-           query: term,
-           operator: "AND"
++      size: 500,
++      terminate_after: 500,
++      timeout: "10s",
++      sort: [
++        %{"_timestamp" => "desc"}
++      ],
+       query: %{
+         bool: %{
+           must: Parsers.Activity.parse(query)
          }
        }
      }
    end
  
-   defp to_es({:quoted, term}), do: to_es(term)
-   defp to_es({:filter, ["hashtag", query]}) do
+   defp es_query(:user, query) do
      %{
-       term: %{
-         hashtags: %{
-           value: query
++      size: 50,
++      terminate_after: 50,
++      timeout: "10s",
++      sort: [
++        %{"_timestamp" => "desc"}
++      ],
+       query: %{
+         bool: %{
+           must: Parsers.User.parse(query)
          }
        }
      }
    end
  
-   defp to_es({:filter, [field, query]}) do
+   defp es_query(:hashtag, query) do
      %{
-       term: %{
-         field => %{
-           value: query
++      size: 50,
++      terminate_after: 50,
++      timeout: "10s",
+       query: %{
+         bool: %{
+           must: Parsers.Hashtag.parse(query)
          }
        }
      }