func urlEncode(pipeline string, params map[string]string) string {
	values := url.Values{}
	for key, val := range params {
		values.Add(key, string(val))
	}
	if pipeline != "" {
		values.Add("pipeline", pipeline)
	}
	return values.Encode()
}
Encode parameters in url
package elasticsearch
import (
	"fmt"
	"net"
	"net/url"
	"strings"
)
func getURL(defaultScheme string, defaultPath string, rawURL string) (string, error) {
	if defaultScheme == "" {
		defaultScheme = "http"
	}
	addr, err := url.Parse(rawURL)
	if err != nil {
		return "", err
	}
	scheme := addr.Scheme
	host := addr.Host
	port := "9200"
	if addr.Scheme == "" || (addr.Host == "" && addr.Path == "" && addr.Opaque != "") {
		rawURL = fmt.Sprintf("%v://%v", defaultScheme, rawURL)
		if tmpAddr, err := url.Parse(rawURL); err == nil {
			addr = tmpAddr
			scheme = addr.Scheme
			host = addr.Host
		} else {
			scheme = defaultScheme
			host = addr.Path
			addr.Path = ""
		}
	}
	if host == "" {
		host = "localhost"
	} else {
		if splitHost, splitPort, err := net.SplitHostPort(host); err == nil {
			host = splitHost
			port = splitPort
		}
		if strings.Count(host, ":") > 1 && strings.Count(host, "]") == 0 {
			host = "[" + host + "]"
		}
	}
	if addr.Path == "" {
		addr.Path = defaultPath
	}
	addr.Scheme = scheme
	addr.Host = host + ":" + port
	return addr.String(), nil
}
func makeURL(url, path, pipeline string, params map[string]string) string {
	if len(params) == 0 && pipeline == "" {
		return url + path
	}
	return strings.Join([]string{
		url, path, "?", urlEncode(pipeline, params),
	}, "")
}