This commit is contained in:
FloatingGhost 2021-12-14 14:28:15 +00:00
parent cc4c5f22f4
commit 9d5d964bf8
5 changed files with 33 additions and 28 deletions

View file

@ -4,7 +4,6 @@
defmodule Mix.Tasks.Pleroma.Activity do
alias Pleroma.Activity
alias Pleroma.Activity.Search
alias Pleroma.User
alias Pleroma.Web.CommonAPI
alias Pleroma.Pagination

View file

@ -46,20 +46,25 @@ def maybe_put_into_elasticsearch(_) do
end
def put(%Activity{} = activity) do
{:ok, _} = Elastix.Document.index(
{:ok, _} =
Elastix.Document.index(
url(),
"activities",
"activity",
DocumentMappings.Activity.id(activity),
DocumentMappings.Activity.encode(activity)
)
{:ok, _} = bulk_post(
activity.object.hashtags, :hashtags
{:ok, _} =
bulk_post(
activity.object.hashtags,
:hashtags
)
end
def put(%User{} = user) do
{:ok, _ } = Elastix.Document.index(
{:ok, _} =
Elastix.Document.index(
url(),
"users",
"user",
@ -87,7 +92,8 @@ def bulk_post(data, :activities) do
end)
|> List.flatten()
{:ok, %{body: %{"errors" => false}}} = Elastix.Bulk.post(
{:ok, %{body: %{"errors" => false}}} =
Elastix.Bulk.post(
url(),
d,
index: "activities",

View file

@ -3,7 +3,7 @@ defp to_es(term) when is_binary(term) do
%{
term: %{
hashtag: %{
value: String.downcase(term),
value: String.downcase(term)
}
}
}