The Problem We Were Actually Solving

We needed a high-performance system to index and retrieve documents from a large corpus of data. The catch was that our users cared not only about the speed of the search but also the accuracy of the results. This meant that THE had to be able to handle various query types, including Boolean searches and phrase matching, while providing relevant rankings. In other words, THE was not just a search engine but a critical component of our application's user experience.

What We Tried First (And Why It Failed)

Initially, we implemented THE using a generic event-driven architecture, leveraging our existing event bus and worker queue. Each query was dispatched as an event, processed in a separate worker thread, and then returned to the client. While this approach seemed elegant, it quickly hit its limits. The event bus was too chatty, causing network overhead and delays, while the worker queue introduced latency and jitter. Most frustratingly, our users reported incorrect results and query timeouts, which we attributed to the threading model and lack of proper synchronization.

The Architecture Decision