diff options
author | Lain Soykaf <lain@lain.com> | 2024-05-23 14:38:30 +0400 |
---|---|---|
committer | Lain Soykaf <lain@lain.com> | 2024-05-23 14:38:30 +0400 |
commit | 94e4f215896dc7976a54fd146daf3e286602925a (patch) | |
tree | 34cdc2812b09154ddecebe910ab6b9880aba15f0 /lib | |
parent | f726e5fbbdab89dd2a8cb498112ed6866047d3d1 (diff) | |
download | pleroma-94e4f215896dc7976a54fd146daf3e286602925a.tar.gz pleroma-94e4f215896dc7976a54fd146daf3e286602925a.zip |
QdrantSearch: Deal with actor restrictions
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/search/qdrant_search.ex | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/pleroma/search/qdrant_search.ex b/lib/pleroma/search/qdrant_search.ex index 283c43075..9cb34ef71 100644 --- a/lib/pleroma/search/qdrant_search.ex +++ b/lib/pleroma/search/qdrant_search.ex @@ -43,23 +43,41 @@ defmodule Pleroma.Search.QdrantSearch do end end + defp actor_from_activity(%{data: %{"actor" => actor}}) do + actor + end + + defp actor_from_activity(_), do: nil + defp build_index_payload(activity, embedding) do + actor = actor_from_activity(activity) + published_at = activity.data["published"] + %{ points: [ %{ id: activity.id |> FlakeId.from_string() |> Ecto.UUID.cast!(), - vector: embedding + vector: embedding, + payload: %{actor: actor, published_at: published_at} } ] } end defp build_search_payload(embedding, options) do - %{ + base = %{ vector: embedding, limit: options[:limit] || 20, offset: options[:offset] || 0 } + + if options[:actor] do + Map.put(base, :filter, %{ + must: [%{key: "actor", match: %{value: options[:actor].ap_id}}] + }) + else + base + end end @impl true |