Add a reindex option
Signed-off-by: Ekaterina Vaartis <vaartis@kotobank.ch>
This commit is contained in:
parent
4445421297
commit
e928e307f3
|
@ -11,9 +11,11 @@ defmodule Mix.Tasks.Pleroma.Search.Meilisearch do
|
||||||
|
|
||||||
import Pleroma.Search.Meilisearch, only: [meili_post!: 2, meili_delete!: 1, meili_get!: 1]
|
import Pleroma.Search.Meilisearch, only: [meili_post!: 2, meili_delete!: 1, meili_get!: 1]
|
||||||
|
|
||||||
def run(["index"]) do
|
def run(["index" | args]) do
|
||||||
start_pleroma()
|
start_pleroma()
|
||||||
|
|
||||||
|
is_reindex = "--reindex" in args
|
||||||
|
|
||||||
meili_post!(
|
meili_post!(
|
||||||
"/indexes/objects/settings/ranking-rules",
|
"/indexes/objects/settings/ranking-rules",
|
||||||
[
|
[
|
||||||
|
@ -68,6 +70,19 @@ def run(["index"]) do
|
||||||
{[objects], new_acc}
|
{[objects], new_acc}
|
||||||
end)
|
end)
|
||||||
|> Stream.each(fn objects ->
|
|> Stream.each(fn objects ->
|
||||||
|
objects =
|
||||||
|
objects
|
||||||
|
|> Enum.filter(fn o ->
|
||||||
|
if is_reindex do
|
||||||
|
result = meili_get!("/indexes/objects/documents/#{o.id}")
|
||||||
|
|
||||||
|
# Filter out the already indexed documents. This is true when the document does not exist
|
||||||
|
result["errorCode"] == "document_not_found"
|
||||||
|
else
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
result =
|
result =
|
||||||
meili_post!(
|
meili_post!(
|
||||||
"/indexes/objects/documents",
|
"/indexes/objects/documents",
|
||||||
|
|
Loading…
Reference in New Issue