mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-26 07:52:17 +00:00
extra cool
This commit is contained in:
parent
0d7bbee430
commit
8378c3a8bc
|
@ -46,20 +46,25 @@ defmodule Pleroma.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 @@ defmodule Pleroma.Elasticsearch do
|
|||
end)
|
||||
|> List.flatten()
|
||||
|
||||
{:ok, %{body: %{"errors" => false}}} = Elastix.Bulk.post(
|
||||
{:ok, %{body: %{"errors" => false}}} =
|
||||
Elastix.Bulk.post(
|
||||
url(),
|
||||
d,
|
||||
index: "activities",
|
||||
|
@ -115,7 +121,7 @@ defmodule Pleroma.Elasticsearch do
|
|||
)
|
||||
end
|
||||
|
||||
def bulk_post(data, :hashtags) do
|
||||
def bulk_post([] = data, :hashtags) do
|
||||
d =
|
||||
data
|
||||
|> Enum.map(fn d ->
|
||||
|
@ -134,6 +140,8 @@ defmodule Pleroma.Elasticsearch do
|
|||
)
|
||||
end
|
||||
|
||||
def bulk_post(_, :hashtags), do: {:ok, nil}
|
||||
|
||||
def search(:raw, index, type, q) do
|
||||
with {:ok, raw_results} <- Elastix.Search.search(url(), index, [type], q) do
|
||||
results =
|
||||
|
|
|
@ -7,7 +7,7 @@ defmodule Pleroma.Search.Elasticsearch do
|
|||
alias Pleroma.Search.Elasticsearch.Parsers
|
||||
alias Pleroma.Web.Endpoint
|
||||
|
||||
defp es_query(:activity, query) do
|
||||
def es_query(:activity, query) do
|
||||
%{
|
||||
size: 50,
|
||||
terminate_after: 50,
|
||||
|
@ -23,7 +23,7 @@ defmodule Pleroma.Search.Elasticsearch do
|
|||
}
|
||||
end
|
||||
|
||||
defp es_query(:user, query) do
|
||||
def es_query(:user, query) do
|
||||
%{
|
||||
size: 50,
|
||||
terminate_after: 50,
|
||||
|
@ -36,7 +36,7 @@ defmodule Pleroma.Search.Elasticsearch do
|
|||
}
|
||||
end
|
||||
|
||||
defp es_query(:hashtag, query) do
|
||||
def es_query(:hashtag, query) do
|
||||
%{
|
||||
size: 50,
|
||||
terminate_after: 50,
|
||||
|
|
|
@ -3,7 +3,7 @@ defmodule Pleroma.Search.Elasticsearch.Parsers.Hashtag do
|
|||
%{
|
||||
term: %{
|
||||
hashtag: %{
|
||||
value: String.downcase(term),
|
||||
value: String.downcase(term)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue