trieve
Trieveは、全文検索・意味検索・ハイブリッド検索とRAG機能を備えた検索基盤で、ベクターデータベースや埋め込みモデルの管理なしに、開発者がチャンク処理、ランキング、レコメンデーション、分析といった高度な検索機能を実装できるよう支援するSkill。
📜 元の英語説明(参考)
Expert guidance for Trieve, the all-in-one search infrastructure that combines full-text, semantic, and hybrid search with built-in RAG capabilities. Helps developers implement production search with chunking, re-ranking, recommendations, and analytics without managing vector databases or embedding models.
🇯🇵 日本人クリエイター向け解説
Trieveは、全文検索・意味検索・ハイブリッド検索とRAG機能を備えた検索基盤で、ベクターデータベースや埋め込みモデルの管理なしに、開発者がチャンク処理、ランキング、レコメンデーション、分析といった高度な検索機能を実装できるよう支援するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o trieve.zip https://jpskill.com/download/15493.zip && unzip -o trieve.zip && rm trieve.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15493.zip -OutFile "$d\trieve.zip"; Expand-Archive "$d\trieve.zip" -DestinationPath $d -Force; ri "$d\trieve.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
trieve.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
trieveフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Trieve — AI検索インフラストラクチャ
概要
Trieveは、全文検索、セマンティック検索、ハイブリッド検索を、組み込みの RAG 機能と組み合わせたオールインワンの検索インフラストラクチャです。開発者が、ベクトルデータベースや埋め込みモデルを管理することなく、チャンク化、リランキング、レコメンデーション、分析による本番環境検索を実装するのに役立ちます。
手順
データセットとチャンクの管理
データセットを作成し、コンテンツをチャンクとして取り込みます。
// src/search/ingest.ts — ドキュメントを Trieve に取り込む
const TRIEVE_API_URL = "https://api.trieve.ai";
const TRIEVE_API_KEY = process.env.TRIEVE_API_KEY!;
const DATASET_ID = process.env.TRIEVE_DATASET_ID!;
async function trieveFetch(path: string, options?: RequestInit) {
const res = await fetch(`${TRIEVE_API_URL}${path}`, {
...options,
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${TRIEVE_API_KEY}`,
"TR-Dataset": DATASET_ID,
...options?.headers,
},
});
if (!res.ok) throw new Error(`Trieve error: ${await res.text()}`);
return res.json();
}
// チャンク(検索可能なコンテンツの基本的な単位)を作成する
async function ingestChunk(params: {
content: string;
link?: string;
tag_set?: string[];
metadata?: Record<string, any>;
group_tracking_id?: string; // 関連するチャンクをグループ化する(例:同じドキュメント)
}) {
return trieveFetch("/api/chunk", {
method: "POST",
body: JSON.stringify({
chunk_html: params.content, // HTML またはプレーンテキストコンテンツ
link: params.link, // ソース URL
tag_set: params.tag_set, // フィルタリング用のタグ
metadata: params.metadata,
group_tracking_ids: params.group_tracking_id
? [params.group_tracking_id]
: undefined,
upsert_by_tracking_id: true, // 存在する場合は更新、存在しない場合は挿入
}),
});
}
// 大規模なデータセットの一括取り込み
async function bulkIngest(documents: any[]) {
const chunks = documents.flatMap((doc) => {
// 長いドキュメントをより小さなチャンクに分割する
const paragraphs = doc.content.split("\n\n").filter(Boolean);
return paragraphs.map((paragraph: string, index: number) => ({
chunk_html: paragraph,
tracking_id: `${doc.id}-chunk-${index}`,
link: doc.url,
tag_set: doc.tags,
metadata: {
title: doc.title,
author: doc.author,
section_index: index,
},
group_tracking_ids: [doc.id], // 同じドキュメントからのすべてのチャンクを1つのグループにまとめる
}));
});
// 120個ずつのバッチで送信する(API制限)
for (let i = 0; i < chunks.length; i += 120) {
const batch = chunks.slice(i, i + 120);
await trieveFetch("/api/chunks", {
method: "POST",
body: JSON.stringify(batch),
});
console.log(`Ingested ${Math.min(i + 120, chunks.length)}/${chunks.length} chunks`);
}
}
検索
全文検索、セマンティック検索、またはハイブリッド検索を実行します。
// src/search/query.ts — さまざまな戦略で検索する
// ハイブリッド検索 — キーワードマッチングとセマンティック類似性を組み合わせる
async function hybridSearch(query: string, options?: {
filters?: Record<string, any>;
page?: number;
pageSize?: number;
scoreThreshold?: number;
}) {
return trieveFetch("/api/chunk/search", {
method: "POST",
body: JSON.stringify({
query,
search_type: "hybrid", // "fulltext" | "semantic" | "hybrid"
page: options?.page ?? 1,
page_size: options?.pageSize ?? 10,
score_threshold: options?.scoreThreshold ?? 0.3,
get_total_pages: true,
highlight_results: true, // ハイライトされたスニペットを返す
highlight_max_length: 200,
highlight_max_num: 3,
use_weights: true, // キーワードスコアとセマンティックスコアのバランスを取る
filters: options?.filters ? {
must: Object.entries(options.filters).map(([field, value]) => ({
field: `metadata.${field}`,
match_any: Array.isArray(value) ? value : [value],
})),
} : undefined,
}),
});
}
// オートコンプリート / タイプアヘッド検索
async function autocomplete(query: string) {
return trieveFetch("/api/chunk/autocomplete", {
method: "POST",
body: JSON.stringify({
query,
search_type: "fulltext", // 高速化のためにキーワードベース
page_size: 5,
highlight_results: true,
highlight_max_length: 100,
}),
});
}
// グループ検索 — ドキュメントごとにグループ化された結果を返す
async function groupSearch(query: string) {
return trieveFetch("/api/chunk_group/group_oriented_search", {
method: "POST",
body: JSON.stringify({
query,
search_type: "hybrid",
page: 1,
page_size: 10,
group_size: 3, // グループごとに上位3つのチャンクを表示する
}),
});
}
RAG (Retrieval-Augmented Generation)
Trieveの組み込みRAGを使用して、データから回答を生成します。
// src/search/rag.ts — 検索されたコンテキストを使用して回答を生成する
async function ragQuery(question: string) {
const response = await trieveFetch("/api/chunk/generate", {
method: "POST",
body: JSON.stringify({
prev_messages: [
{ role: "user", content: question },
],
// 検索ステップの設定
chunk_filter: null,
search_type: "hybrid",
page_size: 5, // 上位5つのチャンクをコンテキストとして取得する
// 生成ステップの LLM 設定
llm_options: {
completion_first: false, // 最初に検索し、次に生成する
system_prompt: "Answer the user's question based on the provided context. If the context doesn't contain the answer, say so. Cite sources.",
temperature: 0.3, // 事実に基づいた回答を得るために低温にする
max_tokens: 500,
},
highlight_results: true,
}),
});
// レスポンスには、生成された回答とソースチャンクの両方が含まれます
return {
answer: response.message,
sources: response.chunks.map((c: any) => ({
content: c.chunk.chunk_html,
(原文がここで切り詰められています) 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Trieve — AI Search Infrastructure
Overview
Trieve, the all-in-one search infrastructure that combines full-text, semantic, and hybrid search with built-in RAG capabilities. Helps developers implement production search with chunking, re-ranking, recommendations, and analytics without managing vector databases or embedding models.
Instructions
Dataset and Chunk Management
Create a dataset and ingest content as chunks:
// src/search/ingest.ts — Ingest documents into Trieve
const TRIEVE_API_URL = "https://api.trieve.ai";
const TRIEVE_API_KEY = process.env.TRIEVE_API_KEY!;
const DATASET_ID = process.env.TRIEVE_DATASET_ID!;
async function trieveFetch(path: string, options?: RequestInit) {
const res = await fetch(`${TRIEVE_API_URL}${path}`, {
...options,
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${TRIEVE_API_KEY}`,
"TR-Dataset": DATASET_ID,
...options?.headers,
},
});
if (!res.ok) throw new Error(`Trieve error: ${await res.text()}`);
return res.json();
}
// Create a chunk (the fundamental unit of searchable content)
async function ingestChunk(params: {
content: string;
link?: string;
tag_set?: string[];
metadata?: Record<string, any>;
group_tracking_id?: string; // Group related chunks (e.g., same document)
}) {
return trieveFetch("/api/chunk", {
method: "POST",
body: JSON.stringify({
chunk_html: params.content, // HTML or plain text content
link: params.link, // Source URL
tag_set: params.tag_set, // Tags for filtering
metadata: params.metadata,
group_tracking_ids: params.group_tracking_id
? [params.group_tracking_id]
: undefined,
upsert_by_tracking_id: true, // Update if exists, insert if not
}),
});
}
// Bulk ingest for large datasets
async function bulkIngest(documents: any[]) {
const chunks = documents.flatMap((doc) => {
// Split long documents into smaller chunks
const paragraphs = doc.content.split("\n\n").filter(Boolean);
return paragraphs.map((paragraph: string, index: number) => ({
chunk_html: paragraph,
tracking_id: `${doc.id}-chunk-${index}`,
link: doc.url,
tag_set: doc.tags,
metadata: {
title: doc.title,
author: doc.author,
section_index: index,
},
group_tracking_ids: [doc.id], // All chunks from same doc in one group
}));
});
// Send in batches of 120 (API limit)
for (let i = 0; i < chunks.length; i += 120) {
const batch = chunks.slice(i, i + 120);
await trieveFetch("/api/chunks", {
method: "POST",
body: JSON.stringify(batch),
});
console.log(`Ingested ${Math.min(i + 120, chunks.length)}/${chunks.length} chunks`);
}
}
Search
Perform full-text, semantic, or hybrid search:
// src/search/query.ts — Search with different strategies
// Hybrid search — combines keyword matching with semantic similarity
async function hybridSearch(query: string, options?: {
filters?: Record<string, any>;
page?: number;
pageSize?: number;
scoreThreshold?: number;
}) {
return trieveFetch("/api/chunk/search", {
method: "POST",
body: JSON.stringify({
query,
search_type: "hybrid", // "fulltext" | "semantic" | "hybrid"
page: options?.page ?? 1,
page_size: options?.pageSize ?? 10,
score_threshold: options?.scoreThreshold ?? 0.3,
get_total_pages: true,
highlight_results: true, // Return highlighted snippets
highlight_max_length: 200,
highlight_max_num: 3,
use_weights: true, // Balance keyword vs semantic scores
filters: options?.filters ? {
must: Object.entries(options.filters).map(([field, value]) => ({
field: `metadata.${field}`,
match_any: Array.isArray(value) ? value : [value],
})),
} : undefined,
}),
});
}
// Autocomplete / typeahead search
async function autocomplete(query: string) {
return trieveFetch("/api/chunk/autocomplete", {
method: "POST",
body: JSON.stringify({
query,
search_type: "fulltext", // Keyword-based for speed
page_size: 5,
highlight_results: true,
highlight_max_length: 100,
}),
});
}
// Group search — return results grouped by document
async function groupSearch(query: string) {
return trieveFetch("/api/chunk_group/group_oriented_search", {
method: "POST",
body: JSON.stringify({
query,
search_type: "hybrid",
page: 1,
page_size: 10,
group_size: 3, // Show top 3 chunks per group
}),
});
}
RAG (Retrieval-Augmented Generation)
Use Trieve's built-in RAG to generate answers from your data:
// src/search/rag.ts — Generate answers using retrieved context
async function ragQuery(question: string) {
const response = await trieveFetch("/api/chunk/generate", {
method: "POST",
body: JSON.stringify({
prev_messages: [
{ role: "user", content: question },
],
// Search configuration for retrieval step
chunk_filter: null,
search_type: "hybrid",
page_size: 5, // Retrieve top 5 chunks as context
// LLM configuration for generation step
llm_options: {
completion_first: false, // Search first, then generate
system_prompt: "Answer the user's question based on the provided context. If the context doesn't contain the answer, say so. Cite sources.",
temperature: 0.3, // Low temperature for factual answers
max_tokens: 500,
},
highlight_results: true,
}),
});
// Response includes both the generated answer and the source chunks
return {
answer: response.message,
sources: response.chunks.map((c: any) => ({
content: c.chunk.chunk_html,
link: c.chunk.link,
score: c.score,
})),
};
}
// Streaming RAG for real-time response display
async function streamRagQuery(question: string, onChunk: (text: string) => void) {
const response = await fetch(`${TRIEVE_API_URL}/api/chunk/generate`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${TRIEVE_API_KEY}`,
"TR-Dataset": DATASET_ID,
},
body: JSON.stringify({
prev_messages: [{ role: "user", content: question }],
search_type: "hybrid",
page_size: 5,
stream_response: true,
}),
});
const reader = response.body!.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const text = decoder.decode(value);
onChunk(text);
}
}
Recommendations
Get content recommendations based on chunk similarity:
// src/search/recommend.ts — Content recommendations
async function getRecommendations(chunkId: string, limit = 5) {
return trieveFetch("/api/chunk/recommend", {
method: "POST",
body: JSON.stringify({
positive_chunk_ids: [chunkId], // "More like this"
negative_chunk_ids: [], // "Less like this"
limit,
strategy: "average_vector", // Average vectors of positive examples
}),
});
}
// Recommend based on user reading history
async function personalizedRecommendations(readChunkIds: string[], limit = 10) {
return trieveFetch("/api/chunk/recommend", {
method: "POST",
body: JSON.stringify({
positive_chunk_ids: readChunkIds.slice(-5), // Last 5 read articles
negative_chunk_ids: [],
limit,
strategy: "average_vector",
filters: {
must_not: readChunkIds.map((id) => ({ // Exclude already-read content
field: "id",
match_any: [id],
})),
},
}),
});
}
Analytics
Track search performance and user behavior:
// src/search/analytics.ts — Search analytics and click tracking
// Log a search event
async function trackSearch(query: string, results: any[]) {
await trieveFetch("/api/analytics/search", {
method: "POST",
body: JSON.stringify({
query,
search_type: "hybrid",
results: results.map((r) => r.id),
}),
});
}
// Log when a user clicks a search result
async function trackClick(queryId: string, chunkId: string, position: number) {
await trieveFetch("/api/analytics/search/click", {
method: "POST",
body: JSON.stringify({
query_id: queryId,
chunk_id: chunkId,
position, // 1-indexed click position
}),
});
}
// Get search analytics — top queries, no-result queries, CTR
async function getAnalytics(params: { from: string; to: string }) {
const topQueries = await trieveFetch(
`/api/analytics/search/top_queries?from=${params.from}&to=${params.to}`
);
const noResults = await trieveFetch(
`/api/analytics/search/no_result_queries?from=${params.from}&to=${params.to}`
);
return { topQueries, noResults };
}
Installation
# JavaScript/TypeScript SDK
npm install trieve-ts-sdk
# Or use the REST API directly (no SDK needed)
# All examples above use fetch — zero dependencies
Examples
Example 1: Integrating Trieve into an existing application
User request:
Add Trieve to my Next.js app for the AI chat feature. I want streaming responses.
The agent installs the SDK, creates an API route that initializes the Trieve client, configures streaming, selects an appropriate model, and wires up the frontend to consume the stream. It handles error cases and sets up proper environment variable management for the API key.
Example 2: Optimizing search performance
User request:
My Trieve calls are slow and expensive. Help me optimize the setup.
The agent reviews the current implementation, identifies issues (wrong model selection, missing caching, inefficient prompting, no batching), and applies optimizations specific to Trieve's capabilities — adjusting model parameters, adding response caching, and implementing retry logic with exponential backoff.
Guidelines
- Chunk intelligently — Split by paragraphs or sections, not arbitrary character counts; each chunk should be self-contained
- Use groups for documents — Group chunks from the same document so you can search by document or by chunk
- Hybrid search by default — Combines keyword precision with semantic understanding; switch to fulltext only for autocomplete
- Track analytics from day one — No-result queries tell you what content is missing; low-CTR queries reveal relevance issues
- Set score thresholds — Filter out low-confidence results; 0.3 is a good starting point, tune based on your data
- Use tags for filtering — Tags enable fast categorical filters without scanning metadata
- Upsert with tracking IDs — Use
upsert_by_tracking_idto safely re-ingest content without creating duplicates - Stream RAG responses — For user-facing applications, stream the LLM response to reduce perceived latency