Skip to content

Instantly share code, notes, and snippets.

@Akkiesoft
Created May 12, 2023 06:58
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Akkiesoft/d9b705b53de1181e6ce8d1288d49bc10 to your computer and use it in GitHub Desktop.
Save Akkiesoft/d9b705b53de1181e6ce8d1288d49bc10 to your computer and use it in GitHub Desktop.

Misskey 13.12.2のMeilisearch indexリネーム手順

概要

https://misskey-hub.net/docs/releases.html#_13-12-2

Meilisearchの設定にindexが必要になりました。値はMisskeyサーバーのホスト名にすることをお勧めします(アルファベット、ハイフン、アンダーバーのみ使用可能)。例: misskey-io 過去に作成されたnotesインデックスは、<index名>---notesにリネームが必要です。例: misskey-io---notes

前提

  • docker-composeで運用してる環境で実施
  • そうじゃなくてもdocker-compose exec meilisearch を取っ払えば多分同じ

手順

  • API keyの取得
$ source .config/meilisearch.env
$ docker-compose exec meilisearch curl -X GET http://localhost:7700/keys -H "Authorization: Bearer $MEILI_MASTER_KEY"
  • Default Admin API Keyのkeyを仮のenvファイルに格納して使うようにする
$ vi .config/meili-api.env
export MEILI_ADMIN_API_KEY=<キー>

$ source .config/meili-api.env
  • indexの取得。いまはnotesのみ。
$ docker-compose exec meilisearch curl -X GET http://localhost:7700/indexes -H "Authorization: Bearer $MEILI_ADMIN_API_KEY"
{"results":[{"uid":"notes","createdAt":"2023-05-10T14:45:45.25817599Z","updatedAt":"2023-05-12T06:28:53.176409423Z","primaryKey":"id"}],"offset":0,"limit":20,"total":1}
  • あたらしいindexの作成。インデックス名のうしろに「---notes」を付け足したものを作成。
$ docker-compose exec meilisearch curl -X POST http://localhost:7700/indexes -H "Authorization: Bearer $MEILI_ADMIN_API_KEY" -H 'Content-Type: application/json' \
--data-binary '{
    "uid": "mugiko-moe---notes",
    "primaryKey": "id"
  }'
  • 作成後のindexのリスト。2つになっている
$ docker-compose exec meilisearch curl -X GET http://localhost:7700/indexes -H "Authorization: Bearer $MEILI_ADMIN_API_KEY"
{"results":[{"uid":"mugiko-moe---notes","createdAt":"2023-05-10T14:45:45.25817599Z","updatedAt":"2023-05-12T06:50:11.598657956Z","primaryKey":"id"},{"uid":"notes","createdAt":"2023-05-12T06:35:26.419725388Z","updatedAt":"2023-05-12T06:35:26.430011167Z","primaryKey":"id"}],"offset":0,"limit":20,"total":2}
  • ここでコンテナを停止して、バージョンアップの処理(ビルド)をやっておく。その間もMeilisearchはいじるので、Meilisearchだけ起動する
$ docker-compose down
$ docker-compose up meilisearch -d

(別画面を出しといてバージョン追従とかbuildを実行しておく)
  • indexを入れ替える
$ docker-compose exec meilisearch curl -X POST http://localhost:7700/swap-indexes -H "Authorization: Bearer $MEILI_ADMIN_API_KEY" -H 'Content-Type: application/json' \
--data-binary '[
    {
      "indexes": [
        "notes",
        "mugiko-moe---notes"
      ]
    }
]'

結果はこんなかんじ
{"taskUid":2552,"indexUid":null,"status":"enqueued","type":"indexSwap","enqueuedAt":"2023-05-12T06:38:46.918304584Z"}
  • 新しい設定の投入
$ vi .config/default.yml

meilisearch:
  host: meilisearch
  port: 7700
  apiKey: '<KEY>'
  ssl: false
  index: 'mugiko-moe' ←ココ!
  • コンテナの再起動
$ docker-compose down;docker-compose up -d
  • 作業前のデータ検索ができることを確認する
  • 確認が済んだら、notes indexは消してOK
$ docker-compose exec meilisearch curl -X DELETE http://localhost:7700/indexes/notes -H "Authorization: Bearer $MEILI_ADMIN_API_KEY"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment