# Lenses

Four lists of sites that shape a search. Boost, bury, block, or search only the sites you name.

A lens is a list of sites that changes what a search returns. There are four, and each is one field of the search request:

| Lens | Field | What it does |
|---|---|---|
| **Boost** | `boost_domains` | Moves results from these sites ahead of the rest |
| **Bury** | `bury_domains` | Moves results from these sites to the end |
| **Block** | `exclude_domains` | Removes results from these sites |
| **Only** | `include_domains` | Returns results from these sites and no others |

Boost and bury change the order. Block and only change what is in the list. All four are free, and each takes up to 25 sites.

## Writing a site

An entry is a host name, such as `example.com`. A leading `www.`, a scheme or a path is ignored, so `https://www.example.com/blog` means `example.com`.

## Boost

Use boost when you trust some sites more than the rest but still want everything else.

```bash
curl https://api.millionshort.com/v1/search \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "rate limiting with a token bucket",
    "boost_domains": ["example.org", "docs.example.com"]
  }'
```

```python
import os

from millionshort import MillionShort

client = MillionShort(api_key=os.environ["MILLIONSHORT_API_KEY"])

r = client.search(
    "rate limiting with a token bucket",
    boost_domains=["example.org", "docs.example.com"],
)
for hit in r.results:
    print(hit["position"], hit["site"], hit["title"])
```

```ts
import { MillionShort } from 'millionshort';

const client = new MillionShort({ apiKey: process.env.MILLIONSHORT_API_KEY });

const r = await client.search('rate limiting with a token bucket', {
  boostDomains: ['example.org', 'docs.example.com'],
});
for (const hit of r.results) {
  console.log(hit.position, hit.site, hit.title);
}
```

The same call as a tool of the MCP server:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "search",
    "arguments": {
      "query": "rate limiting with a token bucket",
      "boost_domains": [
        "example.org",
        "docs.example.com"
      ]
    }
  }
}
```

A boosted site's results come first, in their own order, then everything else. Boost only reorders what the search found: it does not add results from a site that had none for this query.

## Bury

Use bury for sites you would rather not read but do not want to lose: aggregators, sites that summarise other sites, a competitor's marketing pages.

```bash
curl https://api.millionshort.com/v1/search \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "rate limiting with a token bucket",
    "bury_domains": ["example.net"]
  }'
```

```python
import os

import requests

r = requests.post(
    "https://api.millionshort.com/v1/search",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    json={
        "query": "rate limiting with a token bucket",
        "bury_domains": [
            "example.net"
        ]
    },
    timeout=30,
)
r.raise_for_status()
for hit in r.json()["data"]["results"]:
    print(hit["position"], hit["title"], hit["url"])
```

```ts
const res = await fetch('https://api.millionshort.com/v1/search', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "query": "rate limiting with a token bucket",
    "bury_domains": [
      "example.net"
    ]
  }),
});
if (!res.ok) throw new Error(`POST /v1/search failed: ${res.status}`);
const { data } = (await res.json()) as {
  data: { results: { position: number; title: string; url: string }[] };
};
for (const hit of data.results) console.log(hit.position, hit.title, hit.url);
```

The same call as a tool of the MCP server:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "search",
    "arguments": {
      "query": "rate limiting with a token bucket",
      "bury_domains": [
        "example.net"
      ]
    }
  }
}
```

Buried results go to the end of what the search found. With a short `num_results` they will usually fall off the list; ask for more results if you want to see them.

## Block

Use block for sites you never want: a site you already have, a source your users have rejected, your own domain.

```bash
curl https://api.millionshort.com/v1/search \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "rate limiting with a token bucket",
    "exclude_domains": ["example.com", "example.net"]
  }'
```

```python
import os

import requests

r = requests.post(
    "https://api.millionshort.com/v1/search",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    json={
        "query": "rate limiting with a token bucket",
        "exclude_domains": [
            "example.com",
            "example.net"
        ]
    },
    timeout=30,
)
r.raise_for_status()
for hit in r.json()["data"]["results"]:
    print(hit["position"], hit["title"], hit["url"])
```

```ts
const res = await fetch('https://api.millionshort.com/v1/search', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "query": "rate limiting with a token bucket",
    "exclude_domains": [
      "example.com",
      "example.net"
    ]
  }),
});
if (!res.ok) throw new Error(`POST /v1/search failed: ${res.status}`);
const { data } = (await res.json()) as {
  data: { results: { position: number; title: string; url: string }[] };
};
for (const hit of data.results) console.log(hit.position, hit.title, hit.url);
```

The same call as a tool of the MCP server:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "search",
    "arguments": {
      "query": "rate limiting with a token bucket",
      "exclude_domains": [
        "example.com",
        "example.net"
      ]
    }
  }
}
```

The list is filled from further down, so you still get `num_results` results when there are enough.

## Only

Use only to search inside a set of sites: your documentation and two others, a list of journals, the sites a customer has approved.

```bash
curl https://api.millionshort.com/v1/search \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "token bucket",
    "include_domains": ["example.org", "docs.example.com"],
    "num_results": 20
  }'
```

```python
import os

import requests

r = requests.post(
    "https://api.millionshort.com/v1/search",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    json={
        "query": "token bucket",
        "include_domains": [
            "example.org",
            "docs.example.com"
        ],
        "num_results": 20
    },
    timeout=30,
)
r.raise_for_status()
for hit in r.json()["data"]["results"]:
    print(hit["position"], hit["title"], hit["url"])
```

```ts
const res = await fetch('https://api.millionshort.com/v1/search', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "query": "token bucket",
    "include_domains": [
      "example.org",
      "docs.example.com"
    ],
    "num_results": 20
  }),
});
if (!res.ok) throw new Error(`POST /v1/search failed: ${res.status}`);
const { data } = (await res.json()) as {
  data: { results: { position: number; title: string; url: string }[] };
};
for (const hit of data.results) console.log(hit.position, hit.title, hit.url);
```

The same call as a tool of the MCP server:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "search",
    "arguments": {
      "query": "token bucket",
      "include_domains": [
        "example.org",
        "docs.example.com"
      ],
      "num_results": 20
    }
  }
}
```

Only results from the named sites come back. If those sites have little on the query, the list is short and the response carries a `short_results` warning.

## Together, and with the popularity cut

The lenses combine with each other and with everything else in the request:

- `remove_top_sites` removes by rank; block removes by name. Use both to drop the popular sites and two more you have seen enough of.
- Boost and bury apply to what is left after the cuts.
- `page_types`, `topics` and `safe_search` apply as usual.

`summary.removed.blocked` counts results the block lens took out of the list. As with the popularity cut, some sources apply it before results are counted, so the number can be 0 when the lens plainly worked.

## The same four verbs for page types and topics

Boost, bury, block and only also work on kinds of page and on topics, with the slugs of [topics and page types](https://millionshort.com/docs/search/topics-and-page-types):

| Verb | Sites | Page types | Topics |
|---|---|---|---|
| Only | `include_domains` | `page_types` | `topics` |
| Block | `exclude_domains` | `exclude_page_types` | `exclude_topics` |
| Boost | `boost_domains` | `boost_page_types` | `boost_topics` |
| Bury | `bury_domains` | `bury_page_types` | `bury_topics` |

```json
{ "query": "rust lifetime elision", "boost_page_types": ["documentation", "tutorials"], "bury_page_types": ["forums"], "exclude_page_types": ["listicles"] }
```

The page-type and topic lists act on `web` and `news` results; another source in the same call is named in a `filter_not_applied` warning. `only_domains` and `block_domains` are accepted as other names for `include_domains` and `exclude_domains`.

## Patterns for agents

- **A standing lens per user.** Keep each user's trusted and unwanted sites in your own store and send them with every search. A lens lives in the request, or [Spaces](https://millionshort.com/docs/search/spaces) keep one for you.
- **Two passes.** Search once with no lens, let the model name the sites it does not trust, and search again with those in `exclude_domains`.
- **Stay off what you have.** Put the sites already in your corpus in `exclude_domains` so each search brings something new.
- **A closed world.** For regulated answers, send `include_domains` with the approved sites and nothing else can be cited.
- **Check a site first.** [`POST /v1/domain`](https://millionshort.com/docs/api-reference/domain) says how popular a site is and whether it carries a risk label, before you boost it.

## Saving a lens in a Space

A lens can be saved. A Space holds a `lens` of three lists, `boost`, `bury` and `block`, whose entries are targets: `site:example.org`, `type:forums` or `topic:science`. Its list of sites, with `mode: only` or `mode: boost`, is the fourth verb. Save the Space once and pass its name as `space` on a search, and the lens applies without being sent again.

```json
{
  "name": "Programming, first-hand",
  "mode": "boost",
  "sites": ["docs.example.com", "example.org"],
  "lens": {
    "boost": ["type:documentation", "type:tutorials"],
    "bury": ["type:forums"],
    "block": ["type:listicles", "site:example.net"]
  }
}
```

A list you send in the request replaces the saved one for that search. The [Spaces reference](https://millionshort.com/docs/spaces#the-lens) has the fields, and Spaces are free.

## Over MCP and in the SDKs

The `search` tool of the [MCP server](https://millionshort.com/docs/mcp) takes the same four lists with a key. The SDKs take them as `boost_domains` and so on in Python, and `boostDomains` and so on in TypeScript. In the search page for people, the same four are called boost, bury, block and only.
