A book search system and media for generating a book index corresponding
to a collection of books and for providing context snippets related to a
search string formulated by a user based on the book index are provided.
The book index includes a word hash that represents unique words and an
offset to a location list that stores locations for each instance of the
unique word. The book search system receives the search string from the
user, parses the search string to locate phrases and words, and traverses
the book index to generate a list of locations for each word or phrase
included in the search string. The book search system utilizes a
variable-sized container having a maximum size to store subsets of each
word or phrase included in the list of locations to generate the context
snippets for the search string.