本文へ移動
cccskills
無料GitHub で公開日本語紹介

full-text-search

製品内データの全文検索について、PostgreSQLやElasticsearchの検索経路、権限確認、索引更新、再構築の設計と変更を支援します。

原文原文の説明を見る

Use for product search: FtsSearchRepo, pg_search/pg_like/Elasticsearch, mapping migrations, projections, Outbox sync, reindexing and performance. Excludes agent web search.

lobehub/lobehubスター 83,502(GitHub 83,502 + cccskills 0)
連携ツールDockerPostgreSQL

実行スコア 未検証

インストール方法を見る

こんなときに便利

  • 製品内の検索対象を追加したいとき
  • 検索プロバイダーを変更したいとき
  • マッピングや検索文書を更新したいとき
  • 再インデックスや同期を設計したいとき
  • 検索権限や性能を点検したいとき

日本語での紹介

できること

エージェント、メッセージ、ファイル、ナレッジベースなど、製品内データの全文検索機能を変更するときの設計と実装を案内します。検索要求をリポジトリ経由で処理する構成、PostgreSQL系とElasticsearchのプロバイダー境界、検索用ドキュメントのマッピングや投影、データベース権限の維持を扱います。検索対象を追加する場合は、型、文書スキーマ、検索処理、変更捕捉、再インデックス、継続同期まで関連箇所を確認します。Outboxによる変更同期や、移行時のチェックポイント、世代管理、監視やテストの観点も含みます。

こんなときに便利

製品内の検索対象を増やすとき、検索プロバイダーやマッピングを変更するとき、PostgreSQLからElasticsearchへの移行・再構築を扱うときに向いています。検索結果の権限や同期処理を保ちながら改修したい開発者にも役立ちます。

使い方の例

  • 「新しいデータ種別を全文検索の対象に加える手順を整理してください」
  • 「Elasticsearchのマッピング変更と再インデックスの影響を確認してください」
  • 「同期処理で権限と検索結果の形式が保たれるか点検してください」

注意点

対象は製品内データの検索で、エージェントが使う外部Web検索は含みません。利用可能な検索プロバイダーには pg_search、elasticsearch、pg_like があり、Elasticsearchの操作には設定や運用環境が必要です。原文は関連する開発リポジトリ、データベース、検索サービスでの変更を前提としています。

この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。

資料チェック

SKILL.md の記述から、注意が要る操作と導入の前提を AI が確認しました。点数は実際に動かした結果(実行検証)だけで付けています。

安全面送信・削除・コマンド実行などの扱いが明示されているか
B一部不足同期や検索切替を扱い、明示的な切替条件もある一方、運用操作を伴います。
導入のしやすさ必要なツールや API キーが少ないか、書かれているか
B一部不足Elasticsearch設定やリポジトリ、DB、検索サービスが前提で、導入手順は一部です。

点数には入れていません。 2026年10月26日 時点で AI(OpenAI Codex)が判定しました。目安なので、入れる前に原文も確認してください。

評価が違うと思ったら、見直しを依頼する

どの項目が、なぜ違うと思うかを書いてください。ログインは不要です。内容を SKILL.md と照らし合わせて評価を作り直し、この欄に反映します。

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

含まれるファイル(2)

  • SKILL.md15.9 KB
  • references/mapping-migrations.md14.0 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Product Full-Text Search

This skill covers search over LobeHub-owned product data such as agents, topics, messages, files, knowledge bases, documents, chat groups, and memories. It does not cover the agent's external web search providers under apps/server/src/services/search/ or builtin web-browsing tools.

Architecture

Product reads follow one stable path:

router/service -> createFtsSearchRepo -> FtsSearchRepo -> selected backend -> existing result schema
  • apps/server/src/services/ftsSearch/ owns request-scoped provider selection, Elasticsearch configuration, its HTTP client, and backend telemetry. Routers and domain services must call createFtsSearchRepo; they must not construct providers themselves.
  • packages/database/src/repositories/ftsSearch/ owns the provider-neutral contract and the concrete PostgreSQL and Elasticsearch implementations. Keep public result shapes stable in FtsSearchRepo.
  • packages/types/src/ftsSearch.ts owns the shared searchable-entity list and search domain types.
  • packages/database/src/repositories/ftsSearchDocument/ owns Elasticsearch document schemas, mappings, queryable fields, and source-to-document projection.
  • packages/database/src/schemas/ftsSearchSyncOutbox.ts and packages/database/src/repositories/ftsSearchSyncOutbox/ own durable change capture, claims, retries, dead letters, leases, revision fences, and capture-definition validation.
  • scripts/elasticsearchReindex/ owns the resumable full-backfill command and its operational runtime. Shared database source queries and document construction remain in packages/database/src/repositories/ftsSearchDocument/. apps/server/src/services/ftsSearchSync/ and scripts/elasticsearchSync/ own continuous incremental draining.
  • packages/env/src/ftsSearch.ts owns generic Elasticsearch environment variables.

Provider and Permission Invariants

  • FTS_SEARCH_PROVIDER is a deployment-level provider selector with current values pg_search, elasticsearch, and pg_like. It is not a feature flag or a user rollout. Add another enum value only when its provider covers all entities in FTS_SEARCH_BACKEND_ENTITIES end to end, including mode: 'candidates' when the provider enables ftsSearchCandidateEnabled.
  • Provider errors, missing configuration, and unsupported candidate behavior must remain visible. Never silently retry through another provider. pg_like is an explicitly selected lightweight provider, not an implicit fallback: a missing extension or unreachable service must still fail.
  • packages/database/src/repositories/ftsSearch/postgres/ owns the query, permission, pagination, and hydration layer shared by PostgreSQL providers. pgSearch/ and pgLike/ own only their provider adapter, dialect, and provider-specific candidate behavior. Neither provider directory may import the other, so either provider can be retired without owning shared functionality.
  • Before selecting Elasticsearch, require coverage tests proving that it supports every entity in the provider-neutral backend contract. Do not add per-entity routing between providers.
  • Preserve userId, workspaceId, and caller-agent visibility throughout every provider. Candidate retrieval must not broaden the caller's scope.
  • Where Elasticsearch only supplies candidate IDs, PostgreSQL hydration and parent checks remain the authoritative permission boundary. Do not return raw Elasticsearch hits directly when the existing result path requires database authorization or hydration.
  • Provider implementations return the existing hydrated response types and ordering contract. Do not make routers understand provider-specific result shapes.

Changing a Searchable Entity

Scope for pg_like

pg_like primarily serves individual users with small datasets. Review it for correct matching, permissions, and usable result ordering at that scale. For richer search quality or larger datasets, recommend self-hosted Elasticsearch or Elastic Cloud. Do not add indexes or change the database schema as part of pg_like optimization. Keep repairs bounded; distinguish new implementation bugs from shared provider limitations and deliberate lightweight-search trade-offs. Do not infer a personal-user performance problem from large shared development datasets without representative measurements.

Entity changes

Treat an entity addition or projection change as one cross-layer change. Inspect and update every applicable item:

  1. FTS_SEARCH_DOCUMENT_ENTITIES and shared request/result types.
  2. Search document schema, mapping, text fields, filters, fixtures, and mapping parity tests.
  3. FtsSearchDocumentBuilder, including soft deletion and fanout from related source rows.
  4. PostgreSQL and Elasticsearch backend behavior, permission hydration, pagination, and ranking.
  5. Capture functions/triggers or fanout queries in captureInfrastructure.ts.
  6. Reindex checkpoints, Outbox draining, metrics, and self-host documentation.

Schema fields, mappings, builders, and fixed fixtures must agree. Current mapping fields plus explicit FTS_SEARCH_RETAINED_SOURCE_PROPERTIES must equal the current Zod fields, without overlap. Retained source properties keep older open indexes writable during field removals; keep the builder producing them until those indexes are closed. They must not appear in current query metadata. A field outside the document schema must not appear in a mapping or query field list.

Elasticsearch multi_match query length is bounded by a shared leaf-clause budget divided by the selected query-field count. Adding a field reduces that entity's safe query length, and changing a query analyzer to emit multiple terms per Unicode code point requires revisiting the budget and its field-count regression tests.

Capture, Reindex, and Sync

  • Regular database migrations own durable schema: the revision sequence, Outbox table and indexes, and schema-managed source indexes such as the Memory fanout GIN index.
  • Capture functions and triggers are installed only when an operator explicitly enables the Elasticsearch path. installCaptureInfrastructure() is transactional, definition-checked, idempotent for an exact installation, and fail-closed for partial or altered definitions.
  • Do not install capture for every PostgreSQL-only instance. Do not move a normal schema index into the runtime installer merely because it supports capture.
  • The Outbox coalesces by (entity, document_id). A newer capture resets retry/dead-letter state and allocates a new revision only after locking the conflicting row, preserving same-document commit order.
  • Sequence allocation is non-transactional. Use the existing write fences and committed revision boundary; never treat last_value alone as proof that all earlier Outbox rows are visible.
  • Claims use the precise lease timestamp as a fencing token. A stale worker must not acknowledge, fail, or release work reclaimed by another worker.
  • Permanent failures and exhausted retries become durable dead letters. A drain that creates or observes dead work must fail instead of continuing to publish a successful cutover signal.
  • Full backfill does not replace continuous sync. For the initial PostgreSQL-to-Elasticsearch cutover, keep the application on PostgreSQL until aliases are ready and the Outbox is empty and stable, then switch explicitly. Later mapping upgrades keep searches on the existing Elasticsearch alias until promotion.

The supported operator entrypoints below run from the OSS repository root. A wrapping repository may expose different package scripts; check its package.json before invoking these or the mapping migration commands linked below.

bun run db:install-fts-search-capture
bun run fts-search:reindex -- --status
bun run fts-search:reindex -- --apply --yes
bun run fts-search:sync -- --max-steps=8 --yes
bun run scripts/pgSearchCleanup/index.ts --status
bun run scripts/pgSearchCleanup/index.ts --apply --yes

Mapping Generations

Docker startup runs fts-search-elasticsearch-reindex.cjs --startup --yes after PostgreSQL migrations when the selected provider is Elasticsearch. It blocks serving until index migration and catch-up succeed. Persist the same checkpoint volume across application and migration containers; failed namespace locks still require explicit recovery. Continuous sync remains a separate worker. Hosted and manual workflows keep their explicit migration commands.

For mapping changes, generation operations, repeat/resume behavior, or deployment integration, read Mapping migration workflow. It routes to the public command guide and adds recovery, automation, and local Docker rehearsal rules.

  • Treat managed and Serverless Elasticsearch APIs as capability-constrained. Create operational metadata and control indexes with the smallest portable request, and add topology, storage, or index settings only after verifying that the target service supports them; settings accepted by a self-managed cluster may be rejected by a managed service.
  • Make idempotent Elasticsearch resource creation depend on the structured error type, such as resource_already_exists_exception, not a broad HTTP status range. Preserve any other creation failure and stop before follow-up reads or mutations instead of turning a rejected request into a misleading verification error.

Elasticsearch cannot change an existing field's type or index-time analyzer in place. The code declares the target and Elasticsearch records the live state, per entity:

  • FTS_SEARCH_INDEX_DEFINITIONS[entity].schemaVersion is the declared generation; the fingerprint is sha256 of the mapping plus the shared analysis. Add complete changed-entity definitions in a new ftsSearchDocument/migration/NNNN-meaningful-name/ batch, register it and update current pointers in migration/index.ts. Append expected fingerprints in __tests__/schemaSnapshots.json; preserve published batches and baselines. mappings.test.ts and migration/index.test.ts check current parity, history, version bumps and fingerprint changes. See migration/README.md for ownership. Shared analysis changes alter every entity fingerprint and classify as breaking for every entity; bump all affected versions and rebuild rather than using in-place upgrades.
  • Every physical index <alias>-v<n> or same-schema rebuild <alias>-v<n>-r<runId> carries _meta.{reindex_run_id, schema_version, schema_fingerprint}; the alias marks the live generation. A rebuild suffix is physical identity, not a schema-version bump. Indexes created before fingerprints existed may omit the fingerprint, but still need a valid run ID and schema version for sync readiness. _meta.schema_version wins over the -v<n> suffix because an in-place upgrade advances _meta without renaming the index.
  • The sync runtime accepts an alias that still serves an older generation (upgrade in progress) and refuses one that serves a newer generation or a different fingerprint of the declared version. It writes every change to all open <alias>-v* indexes plus the alias write index, pruning each document to the fields that index maps (every generation is dynamic: strict), so a new generation can be backfilled beside the live one; a bulk work item is acknowledged only when every existing generation accepted it (2xx or 409 conflict).
  • Canonical migration checkpoints remain keyed by (namespace, schemaVersion). Explicit current-version rebuild checkpoints add reindexRunId, so repeated v1 rebuilds never reuse a completed v1 cursor. --apply groups the requested entities by declared version, treats existing aliases as an upgrade (no --fresh-run), leaves existing aliases in place, and emits promotion_pending. A completed first install creates aliases. Promoting a newer generation requires a completed checkpoint, a fingerprint match when targeting the declared version, and an idle target-entity Outbox. Rollback to an older stamped generation can use its metadata without a retained checkpoint; --retire requires in_sync and only closes old generations; explicit --purge installs exact-index templates forbidding auto-creation before deleting eligible closed generations. --in-place requires mappingChange: additive, widens the live index with PUT _mapping, pins the checkpoint to that index, and backfills with external_gte so concurrent sync writes win.
  • Use --apply --rebuild-current --entity=<entity> --yes when projection or capture semantics changed without a physical mapping change and historical documents must be regenerated from PostgreSQL. Deploy runtime support first: sync must recognize -r<runId> generations before one is created. Resume with the reported --run-id=<uuid>. Promote with the exact --generation=<alias>-v<n>-r<uuid> because version-only selection is ambiguous. The old generation remains dual-written for rollback and becomes same-version retirement-eligible only after the promotion records which live run superseded it.
  • Checkpoints are local files, not Drizzle migration history. Preserve ES_REINDEX_STATE_DIR across invocations. Completed runs skip backfill; incomplete runs resume from saved cursors. Mutating CLI commands share a non-expiring Elasticsearch namespace lock, independent of checkpoint location. A failed command retains its lock when its outcome may be uncertain. Before --release-lock=<owner> --yes, stop the previous process and resolve pending requests; never assume age proves it stopped. The lock does not serialize old binaries or external operator actions.
  • Reconciliation is exact only on a first install; once an alias serves an entity, concurrent sync writes make a higher Elasticsearch count legitimate and only a shortfall fails.
  • scripts/elasticsearchReindex/runtime/generationService.ts owns classification (missing, unmanaged, in_sync, drift, upgrade_available, rollback_required), promotion, and retirement; keep them free of Cloud-specific policy.

Read docs/self-hosting/advanced/neon-pg-search-migration.mdx or its Chinese counterpart before changing the operational sequence. When database rollout or index cost affects the design, also use the db-migrations skill and measure the relevant operation on the actual Dev database before adding manual or deferred release steps.

Observability and Product Analytics

  • Server provider metrics and traces live in apps/server/src/services/ftsSearch/observability.ts. Keep labels bounded: entity, provider, operation, outcome, and coarse error type are acceptable; raw queries, user IDs, document IDs, and index contents are not.
  • User-perceived search behavior lives with the open-source Command Menu in src/features/CommandMenu/analytics.ts. Product analytics may cover end-to-end duration, rendered result counts, empty results, result clicks, and abandonment without a Cloud business slot.
  • Measurement or analytics failures must never alter the selected provider's result or error.
  • Backend metrics explain provider cost and latency; frontend events explain what the user actually experienced. Do not substitute one for the other.

Validation

  • Add or update focused tests beside every changed provider, mapping, builder, capture, sync, or analytics module.
  • Preserve boundary tests proving callers use FtsSearchRepo, providers cannot leak raw result shapes, and telemetry failures do not affect search behavior.
  • Test pagination after authorization drops candidates, delete/scope-change priority, concurrent Outbox claims and stale settlements, retry/dead-letter behavior, reindex resume identity, and capture-definition mismatch whenever those paths change.
  • Run bun run check <changed-files...> from the repository root. For migration or database-runtime changes, follow the db-migrations and testing skills and verify against the actual Dev database.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

acceptance

無料概要あり

実際の製品を操作して、利用者が確認できる動作証拠を集め、検証計画に沿った受け入れレポートとして公開するスキルです。

  • 変更後の製品動作を実地で検証したいとき
  • 画面キャプチャなどの証拠を集めたいとき
  • 検証計画とレポートを作成したいとき
lobehub/lobehub8.4万2026年10月26日 更新

add-model-provider

無料概要あり

LobeHubにAIモデルプロバイダーを追加し、実行時連携からモデル表示、設定、ブランド表記、文書化、動作確認まで進めるスキルです。

  • 新しいAIモデルプロバイダーを追加したいとき
  • プロバイダーの設定手順や説明文を更新したいとき
  • 既存プロバイダーへのモデル追加要件を見極めたいとき
lobehub/lobehub8.4万2026年10月26日 更新

add-setting-env

無料概要あり

ユーザー設定の初期値をサーバー側の環境変数で切り替えるため、型定義や設定の組み立て、ユーザーストアへの反映、環境変数の例と説明書きを追加する手順です。

  • 設定の初期値を環境変数で変えたいとき
  • 設定項目をサーバー設定に追加したいとき
  • 環境変数の例と説明を更新したいとき
lobehub/lobehub8.4万2026年10月26日 更新

agent-runtime-hooks

無料概要あり

エージェント実行中の各段階をフックで監視し、ツール呼び出しの模擬・制御や人の承認、圧縮、サブエージェント処理に介入する仕組みを扱います。

  • エージェントの実行状況を記録したいとき
  • ツール結果をテスト用に模擬したいとき
  • Webhookでツール実行を許可・拒否したいとき
lobehub/lobehub8.4万2026年10月26日 更新

agent-signal

無料概要あり

イベントを起点にエージェントのバックグラウンド処理を組み立て、ソース・シグナル・アクション・ポリシーの役割分担や非同期連携を実装するためのスキルです。

  • イベント起点の処理を追加したいとき
  • バックグラウンド処理を非同期化したいとき
  • 重複実行を防ぐ仕組みを整えたいとき
lobehub/lobehub8.4万2026年10月26日 更新

agent-testing-bot

無料概要あり

DiscordやSlackなどの実際のチャットアプリでボットにメッセージを送り、応答を画面で確認する受け入れテストを行うスキルです。

  • 実際のDiscordでボット応答を確かめたいとき
  • SlackやTelegramの会話経路をテストしたいとき
  • macOSアプリ上の操作結果を画面で記録したいとき
lobehub/lobehub8.4万2026年10月26日 更新

lobehub のスキルをすべて見る

このスキルの問題を報告する