func NewClient(options ...ClientOptionFunc) (*Client, error) {
	return DialContext(context.Background(), options...)
}
NewClient creates a new client to work with Elasticsearch.

NewClient, by default, is meant to be long-lived and shared across
your application. If you need a short-lived client, e.g. for request-scope,
consider using NewSimpleClient instead.

The caller can configure the new client by passing configuration options
to the func.

Example:

client, err := elastic.NewClient(
elastic.SetURL("http://127.0.0.1:9200", "http://127.0.0.1:9201"),
elastic.SetBasicAuth("user", "secret"))

If no URL is configured, Elastic uses DefaultURL by default.

If the sniffer is enabled (the default), the new client then sniffes
the cluster via the Nodes Info API
(see https://www.elastic.co/guide/en/elasticsearch/reference/6.2/cluster-nodes-info.html#cluster-nodes-info).
It uses the URLs specified by the caller. The caller is responsible
to only pass a list of URLs of nodes that belong to the same cluster.
This sniffing process is run on startup and periodically.
Use SnifferInterval to set the interval between two sniffs (default is
15 minutes). In other words: By default, the client will find new nodes
in the cluster and remove those that are no longer available every
15 minutes. Disable the sniffer by passing SetSniff(false) to NewClient.

The list of nodes found in the sniffing process will be used to make
connections to the REST API of Elasticsearch. These nodes are also
periodically checked in a shorter time frame. This process is called
a health check. By default, a health check is done every 60 seconds.
You can set a shorter or longer interval by SetHealthcheckInterval.
Disabling health checks is not recommended, but can be done by
SetHealthcheck(false).

Connections are automatically marked as dead or healthy while
making requests to Elasticsearch. When a request fails, Elastic will
call into the Retry strategy which can be specified with SetRetry.
The Retry strategy is also responsible for handling backoff i.e. the time
to wait before starting the next request. There are various standard
backoff implementations, e.g. ExponentialBackoff or SimpleBackoff.
Retries are disabled by default.

If no HttpClient is configured, then http.DefaultClient is used.
You can use your own http.Client with some http.Transport for
advanced scenarios.

An error is also returned when some configuration option is invalid or
the new client cannot sniff the cluster (if enabled).
package elastic
import (
	"bytes"
	"context"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"net/http/httputil"
	"net/url"
	"os"
	"regexp"
	"strings"
	"sync"
	"time"
	"github.com/pkg/errors"
	"github.com/olivere/elastic/config"
)
const (
	Version = "6.2.15"
	DefaultURL = "http://127.0.0.1:9200"
	DefaultScheme = "http"
	DefaultHealthcheckEnabled = true
	DefaultHealthcheckTimeoutStartup = 5 * time.Second
	DefaultHealthcheckTimeout = 1 * time.Second
	DefaultHealthcheckInterval = 60 * time.Second
	DefaultSnifferEnabled = true
	DefaultSnifferInterval = 15 * time.Minute
	DefaultSnifferTimeoutStartup = 5 * time.Second
	DefaultSnifferTimeout = 2 * time.Second
	DefaultSendGetBodyAs = "GET"
	DefaultGzipEnabled = false
	off = -1 * time.Second
)
var (
	ErrNoClient = errors.New("no Elasticsearch node available")
	ErrRetry = errors.New("cannot connect after several retries")
	ErrTimeout = errors.New("timeout")
	noRetries = NewStopRetrier()
)
type ClientOptionFunc func(*Client) error
type Client struct {
	c *http.Client  
	connsMu sync.RWMutex  
	conns   []*conn       
	cindex  int           
	mu                        sync.RWMutex     
	urls                      []string         
	running                   bool             
	errorlog                  Logger           
	infolog                   Logger           
	tracelog                  Logger           
	scheme                    string           
	healthcheckEnabled        bool             
	healthcheckTimeoutStartup time.Duration    
	healthcheckTimeout        time.Duration    
	healthcheckInterval       time.Duration    
	healthcheckStop           chan bool        
	snifferEnabled            bool             
	snifferTimeoutStartup     time.Duration    
	snifferTimeout            time.Duration    
	snifferInterval           time.Duration    
	snifferCallback           SnifferCallback  
	snifferStop               chan bool        
	decoder                   Decoder          
	basicAuth                 bool             
	basicAuthUsername         string           
	basicAuthPassword         string           
	sendGetBodyAs             string           
	gzipEnabled               bool             
	requiredPlugins           []string         
	retrier                   Retrier          
}