January 2020
Intermediate to advanced
640 pages
16h 56m
English
Similar to the approach we followed when we modeled the link graph component, we shall encapsulate the preceding list of operations into a Go interface called Indexer:
type Indexer interface { Index(doc *Document) error FindByID(linkID uuid.UUID) (*Document, error) Search(query Query) (Iterator, error) UpdateScore(linkID uuid.UUID, score float64) error }
The Search method expects a Query type instead of a simple string value as its input argument. This is by design; it offers us the flexibility to expand the indexer's query capabilities further down the road to support richer query semantics without having to modify the signature of the Search method. Here is the definition of the Query type:
type Query