only return create objects for ES search (#165)

Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/165
This commit is contained in:
floatingghost 2022-08-16 23:24:19 +00:00
parent 61641957cb
commit 89ffc01c23
3 changed files with 8 additions and 4 deletions

View file

@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed ### Fixed
- Compatibility with latest meilisearch - Compatibility with latest meilisearch
- Resolution of nested mix tasks (i.e search.meilisearch) in OTP releases - Resolution of nested mix tasks (i.e search.meilisearch) in OTP releases
- Elasticsearch returning likes and repeats, displaying as posts
### Removed ### Removed
- Non-finch HTTP adapters. `:tesla, :adapter` is now highly recommended to be set to the default. - Non-finch HTTP adapters. `:tesla, :adapter` is now highly recommended to be set to the default.

View file

@ -23,7 +23,7 @@ defmodule Pleroma.Search.Elasticsearch do
timeout: "5s", timeout: "5s",
sort: [ sort: [
"_score", "_score",
%{_timestamp: %{order: "desc", format: "basic_date_time"}} %{"_timestamp" => %{order: "desc", format: "basic_date_time"}}
], ],
query: %{ query: %{
bool: %{ bool: %{
@ -62,8 +62,12 @@ defmodule Pleroma.Search.Elasticsearch do
Task.async(fn -> Task.async(fn ->
q = es_query(:activity, parsed_query, offset, limit) q = es_query(:activity, parsed_query, offset, limit)
Pleroma.Search.Elasticsearch.Store.search(:activities, q) :activities
|> Enum.filter(fn x -> Visibility.visible_for_user?(x, user) end) |> Pleroma.Search.Elasticsearch.Store.search(q)
|> Enum.filter(fn x ->
x.data["type"] == "Create" && x.object.data["type"] == "Note" &&
Visibility.visible_for_user?(x, user)
end)
end) end)
activity_results = Task.await(activity_task) activity_results = Task.await(activity_task)

View file

@ -42,7 +42,6 @@ defmodule Pleroma.Search.Elasticsearch.Store do
results results
|> Enum.map(fn result -> result["_id"] end) |> Enum.map(fn result -> result["_id"] end)
|> Pleroma.Activity.all_by_ids_with_object() |> Pleroma.Activity.all_by_ids_with_object()
|> Enum.sort(&(&1.inserted_at >= &2.inserted_at))
else else
e -> e ->
Logger.error(e) Logger.error(e)