Updating the PageRank score for a document

To update the PageRank score for an existing document, we need to construct an update request payload that the go-elastic client will submit to the Elasticsearch cluster via an HTTP POST request. The update payload includes a map with the fields names and values that need to be updated.

To facilitate document updates, the go-elastic client exposes an Update method that expects the following set of arguments:

The following code snippet illustrates how the update request is assembled and passed to the Update method:

If the caller of the UpdateScore method provides a document link ID that does not exist, we want to be able to create a placeholder document containing just the LinkID and PageRank scores. This is facilitated by including the doc_as_upsert flag to our update payload.