commit: 1261c43a7af48ed6e6753461944659391c4c58cc
parent c50f0f31f418037063bd97efcdc0f60b89594212
Author: Lain Soykaf <lain@lain.com>
Date: Tue, 14 May 2024 17:19:36 +0400
SearchBackend: Add create_index
Diffstat:
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/lib/mix/tasks/pleroma/search/indexer.ex b/lib/mix/tasks/pleroma/search/indexer.ex
@@ -8,6 +8,12 @@ defmodule Mix.Tasks.Pleroma.Search.Indexer do
alias Pleroma.Workers.SearchIndexingWorker
+ def run(["create_index"]) do
+ Application.ensure_all_started(:pleroma)
+
+ Pleroma.Config.get([Pleroma.Search, :module]).create_index()
+ end
+
def run(["index" | options]) do
{options, [], []} =
OptionParser.parse(
diff --git a/lib/pleroma/search/qdrant_search.ex b/lib/pleroma/search/qdrant_search.ex
@@ -8,7 +8,8 @@ defmodule Pleroma.Search.QdrantSearch do
import Pleroma.Search.Meilisearch, only: [object_to_search_data: 1]
- def initialize_index() do
+ @impl true
+ def create_index() do
payload = Pleroma.Config.get([Pleroma.Search.QdrantSearch, :qdrant_index_configuration])
QdrantClient.put("/collections/posts", payload)
end
diff --git a/lib/pleroma/search/search_backend.ex b/lib/pleroma/search/search_backend.ex
@@ -21,4 +21,9 @@ defmodule Pleroma.Search.SearchBackend do
from index.
"""
@callback remove_from_index(object :: Pleroma.Object.t()) :: :ok | {:error, any()}
+
+ @doc """
+ Create the index
+ """
+ @callback create_index() :: :ok | {:error, any()}
end