January 2020
Intermediate to advanced
640 pages
16h 56m
English
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 ...