diff --git a/CHANGELOG.md b/CHANGELOG.md index 6124c9b02..b32ae2e16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### Added -- support for fedibird-fe, and API parity for it to function +- support for fedibird-fe, and non-breaking API parity for it to function + +### Fixed +- Compatibility with latest meilisearch +- Resolution of nested mix tasks (i.e search.meilisearch) in OTP releases +- Elasticsearch returning likes and repeats, displaying as posts ### Removed - Non-finch HTTP adapters. `:tesla, :adapter` is now highly recommended to be set to the default. diff --git a/lib/mix/tasks/pleroma/search/meilisearch.ex b/lib/mix/tasks/pleroma/search/meilisearch.ex index d4a83c3cd..27a31afcf 100644 --- a/lib/mix/tasks/pleroma/search/meilisearch.ex +++ b/lib/mix/tasks/pleroma/search/meilisearch.ex @@ -9,7 +9,7 @@ defmodule Mix.Tasks.Pleroma.Search.Meilisearch do import Ecto.Query import Pleroma.Search.Meilisearch, - only: [meili_post: 2, meili_put: 2, meili_get: 1, meili_delete!: 1] + only: [meili_put: 2, meili_get: 1, meili_delete!: 1] def run(["index"]) do start_pleroma() @@ -27,7 +27,7 @@ def run(["index"]) do end {:ok, _} = - meili_post( + meili_put( "/indexes/objects/settings/ranking-rules", [ "published:desc", @@ -41,7 +41,7 @@ def run(["index"]) do ) {:ok, _} = - meili_post( + meili_put( "/indexes/objects/settings/searchable-attributes", [ "content" @@ -91,7 +91,7 @@ def run(["index"]) do ) with {:ok, res} <- result do - if not Map.has_key?(res, "uid") do + if not Map.has_key?(res, "indexUid") do IO.puts("\nFailed to index: #{inspect(result)}") end else diff --git a/lib/pleroma/release_tasks.ex b/lib/pleroma/release_tasks.ex index 1e06aafe4..e43eef070 100644 --- a/lib/pleroma/release_tasks.ex +++ b/lib/pleroma/release_tasks.ex @@ -25,7 +25,7 @@ defp mix_task(task, args) do module = Module.split(module) match?(["Mix", "Tasks", "Pleroma" | _], module) and - String.downcase(List.last(module)) == task + task_match?(module, task) end) if module do @@ -35,6 +35,13 @@ defp mix_task(task, args) do end end + defp task_match?(["Mix", "Tasks", "Pleroma" | module_path], task) do + module_path + |> Enum.join(".") + |> String.downcase() + |> String.equivalent?(String.downcase(task)) + end + def migrate(args) do Mix.Tasks.Pleroma.Ecto.Migrate.run(args) end diff --git a/lib/pleroma/search/elasticsearch.ex b/lib/pleroma/search/elasticsearch.ex index 7c7ca82c8..16b01101a 100644 --- a/lib/pleroma/search/elasticsearch.ex +++ b/lib/pleroma/search/elasticsearch.ex @@ -23,7 +23,7 @@ def es_query(:activity, query, offset, limit) do timeout: "5s", sort: [ "_score", - %{_timestamp: %{order: "desc", format: "basic_date_time"}} + %{"_timestamp" => %{order: "desc", format: "basic_date_time"}} ], query: %{ bool: %{ @@ -62,8 +62,12 @@ def search(user, query, options) do Task.async(fn -> q = es_query(:activity, parsed_query, offset, limit) - Pleroma.Search.Elasticsearch.Store.search(:activities, q) - |> Enum.filter(fn x -> Visibility.visible_for_user?(x, user) end) + :activities + |> 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) activity_results = Task.await(activity_task) diff --git a/lib/pleroma/search/elasticsearch/store.ex b/lib/pleroma/search/elasticsearch/store.ex index 895b76d7f..3b7bbb838 100644 --- a/lib/pleroma/search/elasticsearch/store.ex +++ b/lib/pleroma/search/elasticsearch/store.ex @@ -42,7 +42,6 @@ def search(:activities, q) do results |> Enum.map(fn result -> result["_id"] end) |> Pleroma.Activity.all_by_ids_with_object() - |> Enum.sort(&(&1.inserted_at >= &2.inserted_at)) else e -> Logger.error(e)