01Chapter 1: When database queries are not enoughMost applications start with search implemented as a SQL query. For many systems that is the right place to stay. This chapter gives you criteria for deciding when a database query is enough, when the database's built-in full-text feature is enough, and when the requirements justify a dedicated sear6 min read
02Chapter 2: How an inverted index worksThis chapter assumes you know basic SQL and what a database index is, such as a B-tree on a column. It builds on the previous chapter's question of when to add search. Here you learn the data structure that makes a search service fast.6 min read
03Chapter 3: Text analysis: from raw text to searchable termsThis chapter assumes you know what an inverted index is: a map from each term to the documents that contain it. It also assumes basic SQL and REST knowledge. Here you will see how raw text becomes the terms stored in that map, and why the same process must run on queries.5 min read
04Chapter 4: Ranking results with TF-IDF and BM25This chapter assumes you know how an inverted index maps terms to documents and how text analysis turns raw text into terms. Both are covered in the previous chapters. Here we look at what happens after the index finds the matching documents: putting them in a useful order.6 min read
05Chapter 5: Choosing a search engineThis chapter assumes you know why a system needs search at all, which the earlier chapters on when to add search and on inverted indexes cover. It also assumes you know basic SQL, REST APIs, and the idea of horizontal scaling. Here you compare the engine options and pick one with stated criteria. Th7 min read
06Chapter 6: Designing the index and its mappingThis chapter assumes you know what an inverted index is and how text analysis turns raw text into terms. It also assumes you can read a basic SQL schema. The examples use Elasticsearch-style syntax. OpenSearch is nearly identical, and Solr and others use the same ideas under different names.7 min read
07Chapter 7: Keeping the index in sync with the source of truthThis chapter assumes you know basic SQL transactions, how message queues deliver messages (at-least-once, possible reordering), and the index and mapping design from the previous chapter. It covers how changes in the primary database reach the search index, and which failure modes the pipeline must 6 min read
08Chapter 8: Living with eventual consistencyThis chapter assumes you know basic SQL, REST APIs, and message queues. It also assumes you know what replication means. You should have read the previous chapter on syncing data from the source of truth. The goal is to decide what staleness your product can tolerate and to build the search path so 5 min read
09Chapter 9: Designing search queries: filters, facets, and paginationThis chapter assumes you know the basics of an inverted index, how text fields differ from keyword fields in a mapping, and how a search request reaches a cluster. The examples use Elasticsearch-style syntax. OpenSearch and Solr have equivalent features under different names.6 min read
10Chapter 10: Scaling with shards and replicasThis chapter assumes you know what an inverted index is, how a mapping is defined, and the basics of horizontal scaling and replication from general distributed systems. It covers how a search service spreads one logical index across many machines, and the decisions that are hard to change later.7 min read
11Chapter 11: Reindexing and changing the schema safelyThis chapter assumes you know what an index mapping is (see "Designing the index and its mapping") and how data flows from the source of truth into the index (see "Keeping the index in sync with the source of truth"). It also assumes basic familiarity with REST APIs. The examples use Elasticsearch-s8 min read
12Chapter 12: Failure modes and fallback behaviorThis chapter assumes you know how the search service sits next to the primary database (see the earlier chapters on syncing and consistency), and that you are comfortable with timeouts, retries, and message queues. The goal is to decide, before an incident, what your product does when search is slow7 min read
13Chapter 13: Adding autocompleteAutocomplete (also called typeahead) shows suggestions while the user is still typing. This chapter covers the three common designs, the trade-offs between them, and the operational limits that decide which one fits. It assumes you know the earlier chapters on text analysis, index and mapping design7 min read
14Chapter 14: Enforcing permissions in search resultsThis chapter assumes you know how the search index is built and kept in sync with the source of truth, and that you can read a bool query with filters. It also assumes you are familiar with sessions or tokens for authentication. The goal is to make sure a user never sees a search result, a snippet, 7 min read
15Chapter 15: Measuring and tuning relevanceThis chapter assumes you know how an inverted index and BM25 scoring work, and that you can read a basic Elasticsearch-style query. By the end you should be able to set up a repeatable way to measure search quality and use it to change ranking safely.5 min read