> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kiwifs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Search

> Three tiers of search: grep, SQLite FTS5, and vector embeddings.

KiwiFS provides three tiers of search, from zero-dependency grep to semantic vector similarity. You can start simple and scale up without changing your data or workflow.

## Tier 1: grep

Zero dependencies. Exact string matching. Works everywhere.

```bash theme={null}
kiwifs serve --search grep
```

Best for small knowledge bases or environments where SQLite isn't available.

## Tier 2: SQLite FTS5 (default)

BM25-ranked full-text search powered by SQLite FTS5. Supports boolean operators, phrase matching, and path prefix filtering.

```bash theme={null}
kiwifs serve --search sqlite
```

This is the default. KiwiFS builds and maintains a FTS5 index automatically. Searches are fast even with thousands of pages.

### Query syntax

| Syntax      | Example               | Behavior                           |
| ----------- | --------------------- | ---------------------------------- |
| Keywords    | `payment timeout`     | Match pages containing both terms  |
| Boolean AND | `payment AND timeout` | Explicit AND                       |
| Boolean OR  | `payment OR billing`  | Match pages containing either term |
| Boolean NOT | `payment NOT refund`  | Exclude pages containing a term    |
| Phrase      | `"payment timeout"`   | Match the exact phrase             |

### Trust-ranked search

KiwiFS also offers trust-ranked search at `/api/kiwi/search/verified`. Pages with `status: verified` or `source-of-truth: true` in their frontmatter are boosted in results.

## Tier 3: Vector search

Semantic similarity search using pluggable embedder providers and vector stores. Enable it in `.kiwi/config.toml`:

```toml theme={null}
[search.vector]
enabled = true

[search.vector.embedder]
provider = "openai"
model = "text-embedding-3-small"
api_key = "${OPENAI_API_KEY}"

[search.vector.store]
provider = "sqlite-vec"
```

### Supported embedders

| Provider    | Notes                                              |
| ----------- | -------------------------------------------------- |
| OpenAI      | `text-embedding-3-small`, `text-embedding-3-large` |
| Ollama      | Local models, no API key needed                    |
| Cohere      | `embed-english-v3.0`, multilingual variants        |
| Vertex AI   | Google Cloud embeddings                            |
| Bedrock     | AWS embeddings                                     |
| Custom HTTP | Any endpoint returning a vector array              |

### Supported vector stores

| Store      | Notes                           |
| ---------- | ------------------------------- |
| sqlite-vec | Embedded, zero config (default) |
| Qdrant     | Self-hosted or cloud            |
| pgvector   | PostgreSQL extension            |
| Pinecone   | Cloud-hosted                    |
| Weaviate   | Self-hosted or cloud            |
| Milvus     | Self-hosted or cloud            |

## API endpoints

| Endpoint                    | Method    | Description                |
| --------------------------- | --------- | -------------------------- |
| `/api/kiwi/search`          | GET       | Full-text search           |
| `/api/kiwi/search/verified` | GET       | Trust-ranked search        |
| `/api/kiwi/search/semantic` | GET, POST | Vector similarity search   |
| `/api/kiwi/meta`            | GET       | Frontmatter metadata query |

## MCP tools

| Tool                   | Description                      |
| ---------------------- | -------------------------------- |
| `kiwi_search`          | Full-text search with pagination |
| `kiwi_search_semantic` | Vector similarity search         |
| `kiwi_query_meta`      | Frontmatter metadata query       |
| `kiwi_query`           | DQL queries over metadata        |

See the [Search API reference](/api/search) for detailed endpoint documentation.
