---
title: "How MDN’s site-search works"
description: "MDN's site search builds every page nightly in a GitHub Action, emitting index.json files."
url: "https://swe.quest/articles/how-mdn-s-site-search-works-3d88867dabcc5021"
canonical: "https://hacks.mozilla.org/2021/03/how-mdns-site-search-works/"
source: "Mozilla Hacks"
published: "2021-03-22"
difficulty: "medium"
kind: "Case study"
reading_minutes: 6
tags: ["search","system-design","python"]
---

# How MDN’s site-search works

A post on [Mozilla Hacks](https://swe.quest/sources/mozilla-hacks.md), published 2021-03-22, 6 min read, Case study. Original: [https://hacks.mozilla.org/2021/03/how-mdns-site-search-works/](https://hacks.mozilla.org/2021/03/how-mdns-site-search-works/)

## Summary

MDN's site search builds every page nightly in a GitHub Action, emitting index.json files. A Python script strips the HTML and bulk-publishes about 50,000 documents to a managed Elasticsearch cluster in roughly 3.5 minutes, deleting and recreating the index each day for simplicity. A Django endpoint queries it with elasticsearch-dsl, ranking by phrase and term boosts on title and body plus a Google Analytics-derived popularity score (rank = popularity\*10 + score), and adds "Did you mean" suggestions. The cost of the daily rebuild is a brief window of incomplete results, softened by publishing the most popular en-US Web/ pages first.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Search](https://swe.quest/tags/search.md) (Backend & APIs)
- [System design](https://swe.quest/tags/system-design.md) (Architecture & design)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- Elasticsearch basics ([easy posts on Search](https://swe.quest/tags/search.md?difficulty=easy))
- static site generation

## Keywords

MDN, Elasticsearch, Django, elasticsearch-dsl, GitHub Actions, Jamstack, SWR

## Related posts

- [How GitHub Docs’ new search works](https://swe.quest/articles/how-github-docs-new-search-works-0f03307c816bdb86.md): GitHub Engineering · 2023-03-09 · Medium · 10 min read · Search, JavaScript
  GitHub Docs replaced its in-memory Node.js site search, which loaded serialized indexes from the Git repo for eight languages and five versions, with Elasticsearch.
- [How MDN’s autocomplete search works](https://swe.quest/articles/how-mdn-s-autocomplete-search-works-2a24a3a272638b76.md): Mozilla Hacks · 2021-08-03 · Medium · 5 min read · Search, Frontend, Web performance, JavaScript, React
  MDN Web Docs' autocomplete search runs entirely in the browser.
- [A brief history of code search at GitHub](https://swe.quest/articles/a-brief-history-of-code-search-at-github-ac152c8901d98c95.md): GitHub Engineering · 2021-12-15 · Medium · 13 min read · Search, Scaling, Developer tools
  GitHub's code search evolved from a public-only Solr index plus \`git grep\` for private repos, to a decade-long Elasticsearch deployment that grew to 162 nodes, 1.25PB of storage and over 53 billion indexed files.
- [Managing Elasticsearch Reindex at Scale: Performance, Reliability, and Observability](https://swe.quest/articles/managing-elasticsearch-reindex-at-scale-performance-reliability-and-12c26b4dcf9e376c.md): Palantir · 2026-06-08 · Medium · 14 min read · Search, Schema migrations, Resilience, Observability, System design
  Palantir's Gotham document store rebuilds Elasticsearch indices from its transactional database (the source of truth) rather than using Elasticsearch's \_reindex API, so search keeps serving live traffic throughout.
- [The search for speed in Figma](https://swe.quest/articles/the-search-for-speed-in-figma-06e4c11289fe0686.md): Figma · 2024-10-10 · Medium · 11 min read · Search, Performance engineering, Observability, Cost optimization, Cloud platforms
  Figma's search slowness traced mostly to its own stack, not OpenSearch: OpenSearch's headline 8 ms metric was per-shard time, and only the "took" field in responses reveals overall query latency, which accounted for under 30% of API time.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
