O'Reilly logo

Distributed Computing with Go by V.N. Nikhil Anurag

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

api/index.go

Source file containing code to process and add new terms to the index.

package api import ( "bytes" "encoding/json" "fmt" "net/http" ) // tPayload is used to parse the JSON payload consisting of Token data. type tPayload struct { Token string 'json:"token"' Title string 'json:"title"' DocID string 'json:"doc_id"' LIndex int 'json:"line_index"' Index int 'json:"token_index"' } type tIndex struct { Index int LIndex int } func (ti *tIndex) String() string { return fmt.Sprintf("i: %d, li: %d", ti.Index, ti.LIndex) } type tIndices []tIndex // document - key in Indices represent Line Index. type document struct { Count int DocID string Title string Indices map[int]tIndices } func (d *document) String() string { str := fmt.Sprintf("%s ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required