Designing the Search Index

Designing the Search Index

The index is a designed artifact: the searchable-unit decision, three content-field roles, enrichment as data honesty, and the index-time choices that bind every future query.

Search index design is the first foundation of a site search feature that actually works — and the default of piping the production database into the engine as-is is where bad search can begin. This article gives you four core design decisions the index deserves: choosing the searchable unit, assigning every content field one of three roles, enriching documents with the attributes matching needs, and making the index-time text-processing choices deliberately, because they bind every query the system will ever answer — and it closes with the exclusion list, which is a design decision too.

The index is not the database

A site can end up with a bad search index simply by not designing one. During the build, someone connects the engine to the product or content database, maps the columns across, and moves on. The result is an index full of normalized rows, internal field names, display markup, and template boilerplate — a copy of the database's shape, not a structure built for matching. The results feel wrong from day one, and the tuning that follows fights symptoms whose cause is structural.

The index is a derived, denormalized, purpose-built store. Deriving it starts with the most consequential decision of all: what is a searchable unit?

The answer is a judgment about what a user expects to land on, and it cuts both ways. A product available in twelve colorways is usually one document, with the variants folded in as attributes — a visitor searching for the product wants the product, not twelve near-identical rows crowding out everything else. A nine-thousand-word documentation page is usually several documents, one per major section — a visitor searching for one specific procedure wants to land on that procedure, not at the top of a page with the answer buried at anchor forty.

Getting the unit wrong is expensive in both directions. Too coarse, and results cannot deep-link to the part that matched: the user clicks through and starts a second search, this time with their eyes, inside the page. Too fine, and the results page fills with fragments and duplicates of a single underlying thing. The unit decision deserves to be written down with its rationale, because it is the schema every other decision within this topic builds on.

Every content field has one of three roles

Once the unit is chosen, every field in the document should answer one question: what is this field for? Three roles cover the content fields; the ranking signals introduced below are a separate kind of stored data that ranking reads, and they count as having a role too.

Match fields are what retrieval and ranking read — the title, the body prose, the searchable attribute text. They are analyzed (tokenized, normalized) at index time, they carry the weights the relevance work will tune, and they must be kept clean: stripped of markup, navigation labels, and template boilerplate, because anything present in a match field can rank a document, including the phrase that appears in every page's footer.

Display fields are what the results page renders — the image reference, the price, the text a snippet is built from. They are stored and returned but never matched against. The separation matters in both directions: display payloads bloat matching if they leak into it, and a currency symbol or a template phrase should never be the reason a document ranked.

Filter fields are exact-value attributes: category, brand, availability, numeric ranges. They power facets and constraints, and their defining property is that they hold normalized values, not free text. A brand field containing "Acme", "ACME Corp.", and "acme" is three filter values pretending to be one, and the facet rail downstream will faithfully display the mess. The facet mechanics themselves belong to the faceted-navigation article; what it inherits from here is whether the attributes are worth faceting on.

A compact sketch of a product document with the roles made explicit:

json
{
  "id": "sku-4417",
  "match": {
    "title": "Insulated stainless steel travel mug, 470 ml",
    "body": "Keeps drinks hot for six hours. Fits standard cup holders...",
    "attributes_text": "stainless steel, double-wall, dishwasher-safe"
  },
  "display": {
    "image": "media/4417-hero.jpg",
    "price_cents": 2900,
    "snippet_source": "Keeps drinks hot for six hours..."
  },
  "filter": {
    "category": "drinkware",
    "brand": "acme",
    "material": "stainless-steel",
    "in_stock": true
  },
  "signals": {
    "views_30d": 1240,
    "first_published": "2025-11-02"
  }
}
Field roleRead byFailure when confused
MatchRetrieval and rankingDisplay data in match fields ranks noise — footer phrases and markup become hits
DisplayThe results pageMatch data in display bloats payloads and slows responses
FilterFacets and constraintsFree text in filter fields fractures facets into duplicate, misspelled options

The signals block above previews the next section: behavioral and freshness data stored on the document so ranking can read it. How ranking uses those signals is the relevance article's territory — the index's job is to make sure they exist.

Enrichment: the fields search wishes the data had

Real corpora under-describe themselves. Products are missing categories. Brands are spelled three ways. The attribute a user would naturally filter by — material, compatibility, audience — exists only as a phrase somewhere in the description prose. None of this is the search engine's fault, and engine features can patch only part of it inside the index, without repairing the source data. Elasticsearch, for example, documents ingest pipelines that can extract values from text before indexing, and keyword normalizers that can fold case and accents so "Acme" and "acme" become one value.

Enrichment is the deliberate work of adding the fields matching and filtering need: normalized attributes, consistent categorization, and the behavioral signals — popularity, recency — that ranking will lean on as tie-breakers. Where the raw data is prose, enrichment extracts structure from it; where the data is absent, enrichment is a backlog item for whoever owns the data, not a configuration puzzle for whoever owns the engine.

That sentence carries the honesty this article owes. Search exposes data-quality debt; it does not repair it. When a tuning conversation keeps ending at "the documents don't carry that information," the search team has located a data problem with a data owner, and the professional move is to route it there explicitly rather than compensate with increasingly baroque engine configuration.

Enrichment is also a pipeline, not a one-time backfill. New documents arrive under-described forever — the next catalog import will have the same gaps as the one at launch. Whatever process enriches documents has to run wherever index updates run, which is the index-synchronization article's machinery.

Index-time decisions bind query time

Some of the most consequential search decisions are invisible at query time because they were made when the documents were indexed. Tokenization splits text into matchable terms. Lowercasing and accent folding normalize away case and diacritics. Stemming folds word forms together so "mug" matches "mugs". Each of these runs at index time, and each constrains what any future query can match: a query can only find what the analyzer kept.

Two practical consequences follow. First, changing an existing field's analyzer or field type is a reindex event, not a configuration toggle — documents analyzed under the old rules do not match under the new ones, so the corpus has to be rebuilt. Elasticsearch, for example, documents that except for supported mapping parameters you can't change the mapping or field type of an existing field, while new fields can be added to an existing index through its update mapping API. The zero-downtime mechanics of rebuilding safely belong to the index-synchronization article; the trigger is decided here, and it argues for getting the analysis design roughly right early rather than iterating casually on it.

Second, analysis is per-field. Prose fields want language-aware analysis; identifier fields emphatically do not. A SKU or product code that gets stemmed, lowercased into ambiguity, or split on its hyphens becomes hard to look up exactly — an exact-value query against the analyzed field can miss it, and a full-text query for it can also return documents that share only one of its fragments (in Elasticsearch, for example, the match query's default operator is OR). Identifier fields are indexed exact, as a deliberate exception, and the same per-field logic extends to per-language analyzers, which are the multilingual article's territory.

Engine documentation is the working reference for what the analysis toolchain offers — PostgreSQL's text-search configuration for the database-native route, Elasticsearch's analysis layer as representative of the dedicated-engine class. Capabilities cited here are as of November 2026; verify against current documentation when the decisions are being made for real.

What stays out of the index

Index design ends with the exclusion list, and it is design, not an accident of what the crawler happened to skip. Utility pages, boilerplate-heavy templates, near-duplicate variants, expired content — every low-value document admitted to the index dilutes the results of some future query. The exclusion list earns the same treatment as the unit decision: written down, with rationale, reviewed when the corpus changes shape.

Permissioned content needs an honest sentence of its own. If some users must not see a document, the index either segments it away or filters it at query time — and the filtering has to cover every surface, because search leaks existence in subtle ways: a title in a suggestion, a count in a facet, a snippet in a result. The concept belongs in every index design; the access-control architecture behind it is its own engineering domain outside this topic.

Finally, watch for index bloat as a maintenance smell. Fields that nothing matches on, displays, or filters by accumulate silently — added for a feature that never shipped, copied from the source schema because they were there. A periodic inventory pass against the three roles and the ranking signals keeps the index lean, and "no role" is a deletion, not a shrug.

What the index should contain is this article's question. Keeping it in step with the source of truth as the catalog changes is the synchronization article's; deciding how the fields get weighted when queries arrive is the relevance article's. Between them, these two foundations determine much of what users will ever experience as search quality — which is why they come before any conversation about features.

Project Inquiry