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 name of the index that contains the document to be updated
  • The ID of the document to be updated
  • The document update payload encoded as JSON

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

Get Hands-On Software Engineering with Golang now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.