O'Reilly logo

Distributed Computing with Go by V.N. Nikhil Anurag

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The query resolver – the REST API endpoint

The main aim of /api/query is to find the set of search terms in the inverted index and return a list of document IDs in decreasing order of relevance. Let's look at what we mean by "querying search terms" and "relevance".

Query resolution can be defined as the following set of consecutive tasks:

  1. For each of the search terms, we would like to retrieve all available books in inverted index form.
  2. Next, we would like to store the occurrence counts for all the words within each individual book in a simple look up table (map).
  3. Once we have a map with books and their respective counts, we can convert the look up table into an array of ordered document IDs and their respective scores.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required