January 2020
Intermediate to advanced
640 pages
16h 56m
English
Our first attempt at implementing an in-memory indexer will be based on a popular full-text search package for Go called bleve [1]. While bleve is primarily designed to store its index on disk, it also supports an in-memory index. This makes it an excellent candidate for running unit tests in isolation or for demonstration purposes if we don't want to spin up a much more resource-intensive option such as Elasticsearch.
The full source for the bleve-based Indexer implementation is available in the Chapter06/textindexer/store/memory package in this book's GitHub repository. The definition of the InMemoryBleveIndexer type is pretty straightforward:
type InMemoryBleveIndexer struct { mu sync.RWMutex ...