Don't support meilisearch < 0.24.0, since it breaks things
authorEkaterina Vaartis <vaartis@kotobank.ch>
Mon, 20 Dec 2021 16:05:59 +0000 (19:05 +0300)
committerFloatingGhost <hannah@coffee-and-dreams.uk>
Wed, 29 Jun 2022 19:49:45 +0000 (20:49 +0100)
lib/mix/tasks/pleroma/search/meilisearch.ex

index 021552f7b718d31f069984bca657ae3215722756..5098668ad77d2ed0f0c963620a964bd6d4dbb1f3 100644 (file)
@@ -14,17 +14,29 @@ defmodule Mix.Tasks.Pleroma.Search.Meilisearch do
   def run(["index"]) do
     start_pleroma()
 
+    meili_version =
+      (
+        {:ok, result} = meili_get("/version")
+
+        result["pkgVersion"]
+      )
+
+    # The ranking rule syntax was changed but nothing about that is mentioned in the changelog
+    if not Version.match?(meili_version, ">= 0.24.0") do
+      raise "Meilisearch <0.24.0 not supported"
+    end
+
     {:ok, _} =
       meili_post(
         "/indexes/objects/settings/ranking-rules",
         [
-          "desc(published)",
+          "published:desc",
           "words",
           "exactness",
           "proximity",
-          "wordsPosition",
           "typo",
-          "attribute"
+          "attribute",
+          "sort"
         ]
       )