February 2018
Intermediate to advanced
246 pages
6h 3m
English
Source file contains code responsible for returning sorted results based on search terms.
package api import ( "encoding/json" "net/http" "sort" "github.com/last-ent/distributed-go/chapter7/goophr/librarian/common" ) type docResult struct { DocID string 'json:"doc_id"' Score int 'json:"doc_score"' Indices tIndices 'json:"token_indices"' } type result struct { Count int 'json:"count"' Data []docResult 'json:"data"' } // getResults returns unsorted search results & a map of documents containing tokens. func getResults(out chan tcMsg, count int) tCatalog { tc := tCatalog{} for i := 0; i < count; i++ { dc := <-out tc[dc.Token] = dc.DC } close(out) return tc } func getFScores(docIDScore map[string]int) (map[int][]string, []int) { ...Read now
Unlock full access