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:
- For each of the search terms, we would like to retrieve all available books in inverted index form.
- Next, we would like to store the occurrence counts for all the words within each individual book in a simple look up table (map).
- 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.