Support reindexing meilisearch >=0.24.0
authorEkaterina Vaartis <vaartis@kotobank.ch>
Sat, 13 Nov 2021 12:07:51 +0000 (15:07 +0300)
committerFloatingGhost <hannah@coffee-and-dreams.uk>
Wed, 29 Jun 2022 19:48:44 +0000 (20:48 +0100)
It has has a different error code key

lib/mix/tasks/pleroma/search/meilisearch.ex

index 2a3c3a8b925383d1bf2ad2a3de9853c7407ec1a7..3b134ad3ff9ad664efc409c35a3ea9d0dc50c0f3 100644 (file)
@@ -76,8 +76,14 @@ defmodule Mix.Tasks.Pleroma.Search.Meilisearch do
               if is_reindex do
                 result = meili_get!("/indexes/objects/documents/#{o.id}")
 
+                # With >= 0.24.0 the name for "errorCode" is just "code"
+                error_code_key =
+                  if meili_get!("/version")["pkgVersion"] |> Version.match?(">= 0.24.0"),
+                    do: "code",
+                    else: "errorCode"
+
                 # Filter out the already indexed documents. This is true when the document does not exist
-                result["errorCode"] == "document_not_found"
+                result[error_code_key] == "document_not_found"
               else
                 true
               end