Skip to Content
Hands-On Software Engineering with Golang
book

Hands-On Software Engineering with Golang

by Achilleas Anagnostopoulos
January 2020
Intermediate to advanced
640 pages
16h 56m
English
Packt Publishing
Content preview from Hands-On Software Engineering with Golang

Iterating the list of search results

The bleveIterator type implements the indexer.Iterator interface and is defined as follows:

type bleveIterator struct {
    idx       *InMemoryBleveIndexer
    searchReq *bleve.SearchRequest

    cumIdx uint64
    rsIdx  int
    rs     *bleve.SearchResult

    latchedDoc *index.Document
    lastErr    error
}

The iterator implementation keeps track of two pointers:

  • A pointer to the in-memory indexer instance, which allows the iterator to access the stored documents when the iterator is advanced
  • A pointer to the executed search request, which the iterator uses to trigger new bleve searches once the current page of results has been consumed

To track the position in the paginated search result list, the iterator also maintains two counters:

  • A cumulative ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Software Architecture with Golang

Hands-On Software Architecture with Golang

Jyotiswarup Raiturkar

Publisher Resources

ISBN: 9781838554491Supplemental Content