// UpdateRecord modifies the tags associated with a particular filename in the ES database.
//
// Internally, the key used is the Base64 representation of the filename.
UpdateRecord modifies the tags associated with a particular filename in the ES database.

Internally, the key used is the Base64 representation of the filename.
// UpdateRecord modifies the tags associated with a particular filename in the ES database . // // Internally the key used is the Base64 representation of the filename .
func UpdateRecord(fileName string, tags []string) (string, error) {
	if client == nil {
		return "", fmt.Errorf("Client is nil. Client must be initialized with backend.InitES(URL string)")
	}
	key := base64.StdEncoding.EncodeToString([]byte(fileName))
	esBody, err := json.Marshal(dbRecord{ Name: fileName, Tags: tags,})
	if err != nil {
		return "", fmt.Errorf("Error marshalling DB Record to JSON: %s", err.Error())
	}
	req := esapi.IndexRequest{
		Index: 		"documents",
		DocumentID: key,
		Body: 		strings.NewReader(string(esBody)),
		Refresh: 	"true",
	}
	res, err := req.Do(context.Background(), client)
	if err != nil {
		return "", fmt.Errorf("Error performing ESAPI index request: %s", err.Error())
	}
	defer res.Body.Close()
	if res.IsError() {
    	return "", fmt.Errorf("Got Response Error from ES Database: %s", res.Status())
	}
	var r map[string]interface{}
	if err := json.NewDecoder(res.Body).Decode(&r); err != nil {
		return "", fmt.Errorf("Error parsing the response body: %s", err.Error())
	}
	return fmt.Sprintf("[%s] %s; version=%d", res.Status(), r["result"], int(r["_version"].(float64))), nil
}
func UpdateRecord ( fileName string , tags [ ] string ) ( string , error ) { if client == nil { return " " , fmt . Errorf ( " " ) } key := base64 . StdEncoding . EncodeToString ( [ ] byte ( fileName ) ) esBody , err := json . Marshal ( dbRecord { Name : fileName , Tags : tags , } ) if err != nil { return " " , fmt . Errorf ( " " , err . Error ( ) ) } req := esapi . IndexRequest { Index : " " , DocumentID : key , Body : strings . NewReader ( string ( esBody ) ) , Refresh : " " , } res , err := req . Do ( context . Background ( ) , client ) if err != nil { return " " , fmt . Errorf ( " " , err . Error ( ) ) } defer res . Body . Close ( ) if res . IsError ( ) { return " " , fmt . Errorf ( " " , res . Status ( ) ) } var r map [ string ] interface { } if err := json . NewDecoder ( res . Body ) . Decode ( & r ) ; err != nil { return " " , fmt . Errorf ( " " , err . Error ( ) ) } return fmt . Sprintf ( " " , res . Status ( ) , r [ " " ] , int ( r [ " " ] . ( float64 ) ) ) , nil }
UpdateRecord modifies the tags associated with a particular filename in the ES database.
UpdateRecord modifies the tags associated with a particular filename in the ES database .
// Create the base64 key. // Establish the complete ES record and marshal it to JSON // Deserialize the response into a map.