QdrantSearch: Fetch a post in search if possible.
This commit is contained in:
parent
f4c04e6b2d
commit
ddf103eca0
|
@ -9,6 +9,7 @@ defmodule Pleroma.Search.QdrantSearch do
|
||||||
alias __MODULE__.QdrantClient
|
alias __MODULE__.QdrantClient
|
||||||
|
|
||||||
import Pleroma.Search.Meilisearch, only: [object_to_search_data: 1]
|
import Pleroma.Search.Meilisearch, only: [object_to_search_data: 1]
|
||||||
|
import Pleroma.Search.DatabaseSearch, only: [maybe_fetch: 3]
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def create_index do
|
def create_index do
|
||||||
|
@ -115,8 +116,8 @@ def remove_from_index(object) do
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def search(_user, query, options) do
|
def search(user, original_query, options) do
|
||||||
query = "Represent this sentence for searching relevant passages: #{query}"
|
query = "Represent this sentence for searching relevant passages: #{original_query}"
|
||||||
|
|
||||||
with {:ok, embedding} <- get_embedding(query),
|
with {:ok, embedding} <- get_embedding(query),
|
||||||
{:ok, %{body: %{"result" => result}}} <-
|
{:ok, %{body: %{"result" => result}}} <-
|
||||||
|
@ -134,6 +135,7 @@ def search(_user, query, options) do
|
||||||
|> Activity.restrict_deactivated_users()
|
|> Activity.restrict_deactivated_users()
|
||||||
|> Ecto.Query.order_by([a], fragment("array_position(?, ?)", ^ids, a.id))
|
|> Ecto.Query.order_by([a], fragment("array_position(?, ?)", ^ids, a.id))
|
||||||
|> Pleroma.Repo.all()
|
|> Pleroma.Repo.all()
|
||||||
|
|> maybe_fetch(user, original_query)
|
||||||
else
|
else
|
||||||
_ ->
|
_ ->
|
||||||
[]
|
[]
|
||||||
|
|
Loading…
Reference in New Issue