func NewDefaultClient(addresses []string, username, password string) (*elasticsearch.Client, error) {
	es, err := NewClient(addresses, "", username, password)
	if err != nil {
		return nil, errors.Wrap(err, "eshelper.newclient")
	}
	return es, nil
}
NewDefaultClient returns a new elastic search client
package eshelper
import (
	"bytes"
	"crypto/tls"
	"fmt"
	"io"
	"io/ioutil"
	"net"
	"net/http"
	"net/url"
	"time"
	"github.com/billgraziano/xelogstash/log"
	"github.com/elastic/go-elasticsearch/v7"
	"github.com/elastic/go-elasticsearch/v7/esapi"
	"github.com/pkg/errors"
)
type BulkResponse struct {
	Errors bool `json:"errors"`
	Items  []struct {
		Index struct {
			ID     string `json:"_id"`
			Result string `json:"result"`
			Status int    `json:"status"`
			Error  struct {
				Type   string `json:"type"`
				Reason string `json:"reason"`
				Cause  struct {
					Type   string `json:"type"`
					Reason string `json:"reason"`
				} `json:"caused_by"`
			} `json:"error"`
		} `json:"index"`
	} `json:"items"`
}
func NewClient(addresses []string, proxy, username, password string) (*elasticsearch.Client, error) {
	var t http.Transport
	if proxy == "" {
		t = http.Transport{
			MaxIdleConnsPerHost:   10,
			ResponseHeaderTimeout: 10 * time.Second,
			DialContext:           (&net.Dialer{Timeout: 10 * time.Second}).DialContext,
			TLSClientConfig: &tls.Config{
				MinVersion: tls.VersionTLS12,
			},
		}
	} else {
		parsedURL, err := url.Parse(proxy)
		if err != nil {
			return nil, errors.Wrap(err, "url.parse")
		}
		proxyURL := http.ProxyURL(parsedURL)
		if proxyURL == nil {
			return nil, errors.New("proxyURL is nil")
		}
		t = http.Transport{
			Proxy:                 proxyURL,
			MaxIdleConnsPerHost:   10,
			ResponseHeaderTimeout: time.Second,
			DialContext:           (&net.Dialer{Timeout: time.Second}).DialContext,
			TLSClientConfig: &tls.Config{
				MinVersion: tls.VersionTLS12,
			},
		}
	}
	cfg := elasticsearch.Config{
		Addresses: addresses,
		Username:  username,
		Password:  password,
		Transport: &t,
	}
	es, err := elasticsearch.NewClient(cfg)
	if err != nil {
		return nil, errors.Wrap(err, "elasticsearch.newclient")
	}
	_, err = es.Info()
	if err != nil {
		return nil, errors.Wrap(err, "es.info")
	}
	return es, nil
}