---
title: "類似検索を実装する（エージェント用スキル） | Orchestor"
description: "ベクトルデータベースで効率的な類似検索を実装する。セマンティック検索の構築、最近傍クエリの実装、検索性能の最適化に使う。wshobson/agents が公開している「類似検索を実装する」の使い方を確認できます。"
canonical_url: "https://www.orchestor.io/ja/skills/wshobson/agents/similarity-search-patterns"
markdown_url: "https://www.orchestor.io/ja/skills/wshobson/agents/similarity-search-patterns.md"
---

[c96b5f6](https://github.com/wshobson/agents/commit/c96b5f6552dba32e4492307493ee613581430715)[原文を開く](https://github.com/wshobson/agents/blob/c96b5f6552dba32e4492307493ee613581430715/plugins/llm-application-dev/skills/similarity-search-patterns/SKILL.md)

wshobson2026/11/24

原文 (選択中)

未翻訳

プレビュー (選択中)

64 行（空行を除く 48 行） · 2.71 KB原文

```yaml
name: similarity-search-patterns
description: Implement efficient similarity search with vector databases. Use when building semantic search, implementing nearest neighbor queries, or optimizing retrieval performance.
```

# Similarity Search Patterns

Patterns for implementing efficient similarity search in production systems.

## When to Use This Skill

* Building semantic search systems
* Implementing RAG retrieval
* Creating recommendation engines
* Optimizing search latency
* Scaling to millions of vectors
* Combining semantic and keyword search

## Core Concepts

### 1\. Distance Metrics

| Metric | Formula | Best For | | ------------------ | ------------------ | --------------------- | --- | -------------- | | **Cosine** | 1 - (A·B)/(‖A‖‖B‖) | Normalized embeddings | | **Euclidean (L2)** | √Σ(a-b)² | Raw embeddings | | **Dot Product** | A·B | Magnitude matters | | **Manhattan (L1)** | Σ | a-b | | Sparse vectors |

### 2\. Index Types

```
┌─────────────────────────────────────────────────┐
│                 Index Types                      │
├─────────────┬───────────────┬───────────────────┤
│    Flat     │     HNSW      │    IVF+PQ         │
│ (Exact)     │ (Graph-based) │ (Quantized)       │
├─────────────┼───────────────┼───────────────────┤
│ O(n) search │ O(log n)      │ O(√n)             │
│ 100% recall │ ~95-99%       │ ~90-95%           │
│ Small data  │ Medium-Large  │ Very Large        │
└─────────────┴───────────────┴───────────────────┘
```

## Templates and detailed worked examples

Full template library and detailed worked examples live in details.md. Read that file when you need the concrete templates.

## Best Practices

### Do's

* **Use appropriate index** \- HNSW for most cases
* **Tune parameters** \- ef\_search, nprobe for recall/speed
* **Implement hybrid search** \- Combine with keyword search
* **Monitor recall** \- Measure search quality
* **Pre-filter when possible** \- Reduce search space

### Don'ts

* **Don't skip evaluation** \- Measure before optimizing
* **Don't over-index** \- Start with flat, scale up
* **Don't ignore latency** \- P99 matters for UX
* **Don't forget costs** \- Vector storage adds up

## Structured data

```json
[
  [
    {
      "@context": "https://schema.org",
      "@type": "Organization",
      "name": "Orchestor",
      "url": "https://www.orchestor.io",
      "sameAs": [
        "https://orchestor.io",
        "https://www.orchestor.io",
        "https://docs.orchestor.io"
      ],
      "@id": "https://www.orchestor.io/#organization",
      "alternateName": [
        "オーケスター"
      ],
      "logo": "https://www.orchestor.io/images/common/ogp/orchestor-ogp.png",
      "parentOrganization": {
        "@type": "Organization",
        "name": "ドットメディア株式会社",
        "url": "https://www.dotmedia.co.jp"
      }
    },
    {
      "@context": "https://schema.org",
      "@type": "WebSite",
      "url": "https://www.orchestor.io",
      "name": "Orchestor",
      "description": "Orchestor で画像・動画・音声を作り、参照素材を Remix できます。",
      "@id": "https://www.orchestor.io/#website",
      "alternateName": [
        "オーケスター"
      ],
      "inLanguage": "ja",
      "publisher": {
        "@id": "https://www.orchestor.io/#organization"
      }
    }
  ],
  {
    "@context": "https://schema.org",
    "@type": "BreadcrumbList",
    "@id": "https://www.orchestor.io/skills/wshobson/agents/similarity-search-patterns#breadcrumb",
    "itemListElement": [
      {
        "@type": "ListItem",
        "position": 1,
        "name": "Orchestor",
        "item": "https://www.orchestor.io/"
      },
      {
        "@type": "ListItem",
        "position": 2,
        "name": "スキル",
        "item": "https://www.orchestor.io/skills"
      },
      {
        "@type": "ListItem",
        "position": 3,
        "name": "類似検索を実装する",
        "item": "https://www.orchestor.io/skills/wshobson/agents/similarity-search-patterns"
      }
    ]
  }
]
```

---

[Documentation index](https://www.orchestor.io/llms.txt)
