Skip to content

[wip] feat: Meilisearchの再インデックスをコントロールパネルから出来るようにする#16133

Draft
samunohito wants to merge 5 commits intomisskey-dev:developfrom
samunohito:feat/10789-re-index-meilisearch
Draft

[wip] feat: Meilisearchの再インデックスをコントロールパネルから出来るようにする#16133
samunohito wants to merge 5 commits intomisskey-dev:developfrom
samunohito:feat/10789-re-index-meilisearch

Conversation

@samunohito
Copy link
Copy Markdown
Member

What

あとからMeilisearchに切り替えた後でも、切り替える以前のノートをコントロールパネルからマイグレーション出来るようになります。

Why

fix #10789

Additional info (optional)

Checklist

  • Read the contribution guide
  • Test working in a local environment
  • (If needed) Add story of storybook
  • (If needed) Update CHANGELOG.md
  • (If possible) Add tests

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 31, 2025

このPRによるapi.jsonの差分
差分はありません。
Get diff files from Workflow Page

@codecov
Copy link
Copy Markdown

codecov Bot commented May 31, 2025

Codecov Report

❌ Patch coverage is 20.74074% with 107 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.79%. Comparing base (a888f28) to head (d5c184a).
⚠️ Report is 400 commits behind head on develop.

Files with missing lines Patch % Lines
packages/backend/src/core/SearchService.ts 20.74% 107 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #16133      +/-   ##
===========================================
- Coverage    45.86%   45.79%   -0.08%     
===========================================
  Files         1781     1781              
  Lines       184646   184766     +120     
  Branches      5514     5511       -3     
===========================================
- Hits         84695    84607      -88     
- Misses       99922   100119     +197     
- Partials        29       40      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


@Injectable()
export class SearchService {
public static MeilisearchNotActiveError = class extends Error {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IdentifiableError にするかこういうふうにするかをそろそろ定めたほうが良さそう...

(IdentifiableErrorのuuidを static 変数にすればいいかなと思ってる)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

エラーを定義する方針を決めるIssue、立てますか。

@samunohito samunohito requested a review from Copilot October 31, 2025 23:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds re-indexing functionality for Meilisearch notes in the SearchService. The changes enable batch re-indexing of notes within a specific date range and improve code organization by extracting common document addition logic.

  • Adds a new reIndexNotes method to re-index notes in Meilisearch for a specified date range
  • Extracts document addition logic into a reusable addDocument method
  • Adds unindexNoteAll method to clear all indexed documents
  • Includes minor code formatting improvements

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/backend/src/core/SearchService.ts Outdated

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
while (true) {
const notes = await fetchNote(sinceId, untilId, fetchedCount, 100);
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pagination logic is incorrect. fetchedCount is passed as the take parameter but it's meant to track the total count of processed notes, not to paginate through results. The loop will always fetch the same notes because there's no cursor-based pagination (no lastNoteId is used in the next iteration). Change the logic to use lastNoteId as the untilId parameter for subsequent iterations: await fetchNote(sinceId, lastNoteId ?? untilId, undefined, 100).

Suggested change
const notes = await fetchNote(sinceId, untilId, fetchedCount, 100);
const notes = await fetchNote(sinceId, lastNoteId ?? untilId, 100, 100);

Copilot uses AI. Check for mistakes.
Comment thread packages/backend/src/core/SearchService.ts
Comment thread packages/backend/src/core/SearchService.ts Outdated
@samunohito
Copy link
Copy Markdown
Member Author

どこに起動用のボタンを置くか悩み中(最悪cliでもいい?)

@syuilo
Copy link
Copy Markdown
Member

syuilo commented Nov 4, 2025

最悪cliでもよさそう

@samunohito
Copy link
Copy Markdown
Member Author

とりあえずcliで(リクエストあったら何処かに生やす方針)

@syuilo
Copy link
Copy Markdown
Member

syuilo commented Nov 4, 2025

API自体は生えてる感じかしら

@samunohito
Copy link
Copy Markdown
Member Author

Meilisearchの再インデックス機能そのものが存在してなくて、このprで実装してる感じです(Serviceだけ実装して止まってる)

@syuilo
Copy link
Copy Markdown
Member

syuilo commented Nov 4, 2025

APIはあっても良さそう

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packages/backend Server side specific issue/PR

Projects

Development

Successfully merging this pull request may close these issues.

[13.12.0 beta.5]Meilisearchで導入以前の過去のノートを検索できるようにマイグレーションしたい

4 participants