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

Indexing and looking up documents

To upsert a document to the index, we need to submit an update operation to the Elasticsearch cluster. The update request's contents is populated using the following block of code:

esDoc := makeEsDoc(doc)
update := map[string]interface{}{
    "doc":           esDoc,
    "doc_as_upsert": true,
}

The makeEsDoc helper converts the input indexer.Document instance into a representation that Elasticsearch can process. It is important to note that the mapped document does not include a PageRank score value, even if that is present in the original docs. This is intentional as we only allow PageRank scores to be mutated via a call to UpdateScore. The doc_as_upsert flag serves as a hint to Elasticsearch that it should create the document ...

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