# Long-tail research

A method for finding what the first page of any search engine does not show you.

The first page of results for most questions is the same few sites. Research that stops there repeats what everyone already read. This guide is a method for going past it on purpose, with working code.

## The idea

Run the same query at several depths and compare what comes back:

| Pass | Request | What it shows |
|---|---|---|
| The head | `only_top_sites: 1000` | What the well-known sites say. Your baseline |
| The middle | `remove_top_sites: 1000` | Specialist publishers and trade sites |
| The tail | `remove_top_sites: 100000` | Small sites, clubs, personal pages, first-hand accounts |
| The small web | `sources: ["smallweb"]` | Independent writers, as a source of its own |
| The conversation | `sources: ["discussions"]` | What people who did it say to each other |

Each pass is one search and costs 1 credit. Five passes cost 5 credits.

## Run the passes

```python
import os

from millionshort import MillionShort

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

QUERY = "restoring a cast iron skillet"
PASSES = {
    "head": {"only_top_sites": 1000},
    "middle": {"remove_top_sites": 1000},
    "tail": {"remove_top_sites": 100000},
    "small web": {"sources": ["smallweb"]},
    "conversation": {"sources": ["discussions"]},
}

seen, spent = set(), 0.0
for name, options in PASSES.items():
    r = client.search(QUERY, num_results=10, exclude_risky=True, **options)
    spent += r.usage.credits
    print(f"\n== {name}")
    for hit in r.results:
        if hit["url"] in seen:
            continue
        seen.add(hit["url"])
        print(f'{hit["popularity"]["bucket"]:>9}  {hit["site"]}  {hit["title"][:70]}')
print(f"\n{len(seen)} distinct pages for {spent} credits")
```

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

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

const QUERY = 'restoring a cast iron skillet';
const PASSES = {
  head: { onlyTopSites: 1000 },
  middle: { removeTopSites: 1000 },
  tail: { removeTopSites: 100000 },
  'small web': { sources: ['smallweb'] },
  conversation: { sources: ['discussions'] },
};

const seen = new Set<string>();
let spent = 0;
for (const [name, options] of Object.entries(PASSES)) {
  const r = await client.search(QUERY, { numResults: 10, excludeRisky: true, ...options });
  spent += r.usage?.credits ?? 0;
  console.log(`\n== ${name}`);
  for (const hit of r.results) {
    if (seen.has(hit.url)) continue;
    seen.add(hit.url);
    console.log(hit.popularity.bucket.padStart(9), hit.site, hit.title.slice(0, 70));
  }
}
console.log(`\n${seen.size} distinct pages for ${spent} credits`);
```

## Read the tail critically

The long tail holds the best pages on the web and some of the worst. Less popular does not mean more true. Before you rely on a page:

- **Look at `risk`.** Skip anything that carries a label unless you have a reason. `exclude_risky: true`, as in the code above, does it in the request.
- **Ask why it ranked.** Add `"explain": true` and read `why` and `signals`: a page with the query in its title, a reasonable length in `words` and some `link_authority` is a different thing from a thin page that matched two words.
- **Narrow by kind of page.** `page_types: ["articles", "blogs", "tutorials", "forums"]` keeps writing and drops shop pages and directories, and `exclude_page_types` names the kinds to drop instead. Both act on `web` and `news` results. `GET /v1/sources` lists the slugs.
- **Find a second source.** A claim found once in the tail is a lead. Search for the claim itself, and see who else says it.
- **Check the site.** [`POST /v1/domain`](https://millionshort.com/docs/api-reference/domain) returns popularity and risk for up to 25 sites in one call.

## Follow a good find

When one page is clearly written by someone who knows the subject:

1. **Search that site alone**: `include_domains: ["example.org"]` with a broader query shows what else they wrote.
2. **Search around it**: put the sites you have already read in `exclude_domains` and run the query again, so each pass brings something new.
3. **Move it up**: `boost_domains` keeps a trusted site at the top of later searches on the same subject.

```bash
curl https://api.millionshort.com/v1/search \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "cast iron seasoning",
    "include_domains": ["example.org"],
    "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": "cast iron seasoning",
        "include_domains": [
            "example.org"
        ],
        "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": "cast iron seasoning",
    "include_domains": [
      "example.org"
    ],
    "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": "cast iron seasoning",
      "include_domains": [
        "example.org"
      ],
      "num_results": 20
    }
  }
}
```

## Primary sources

For some questions the tail is not a blog but a record. Ask the source that holds it:

- What a company itself said: `finance`.
- What the statute or the opinion says: `law`.
- Who was awarded the contract: `contracts`.
- The paper, not the article about the paper: `academic` or `medical`.

Each has its own page under [the sources](https://millionshort.com/docs/search/sources), with the fields its results carry.

## Limits to keep in mind

- The `web` source is refreshed periodically and its results carry no date. For anything recent, add `news` or `social`. See [Freshness](https://millionshort.com/docs/search/freshness).
- Popularity belongs to the site, not the page: a personal page hosted on a large platform carries the platform's rank and is removed with it. The `smallweb` pass is there to catch those.
- A snippet is up to 2,000 characters of a page, not the page. `include_content: true` adds the page text we hold to `web` and `news` results, as it was when we captured it. Read the page itself before you quote it.

## Next

- [Remove the top sites](https://millionshort.com/docs/search/remove-top-sites) and [Lenses](https://millionshort.com/docs/search/lenses), in full.
- Use cases: [primary-source research](https://millionshort.com/docs/use-cases/primary-source-research) and [research agents](https://millionshort.com/docs/use-cases/research-agents).
- Glossary: [What is long-tail search?](https://millionshort.com/docs/glossary/what-is-long-tail-search)
