// DeleteRecord removes a record from the ES database but not its corresponding file in the filesystem.
DeleteRecord removes a record from the ES database but not its corresponding file in the filesystem.
// DeleteRecord removes a record from the ES database but not its corresponding file in the filesystem .
func DeleteRecord(fileName 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))
	req := esapi.DeleteRequest{
		Index: "documents",
		DocumentID: key,
	}
	res, err := req.Do(context.Background(), client)
	if err != nil {
		return "", fmt.Errorf("Error performing ESAPI delete 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 DeleteRecord ( fileName string ) ( string , error ) { if client == nil { return " " , fmt . Errorf ( " " ) } key := base64 . StdEncoding . EncodeToString ( [ ] byte ( fileName ) ) req := esapi . DeleteRequest { Index : " " , DocumentID : key , } 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 }
DeleteRecord removes a record from the ES database but not its corresponding file in the filesystem.
DeleteRecord removes a record from the ES database but not its corresponding file in the filesystem .
// Deserialize the response into a map.