go-elasticsearch.go 501 B

123456789101112131415161718192021222324
  1. package services
  2. import (
  3. "github.com/elastic/go-elasticsearch/v7"
  4. )
  5. /*
  6. Addresses []string // A list of Elasticsearch nodes to use.
  7. Logger estransport.Logger // The logger object.
  8. Selector estransport.Selector // The selector object.
  9. */
  10. // 官方库
  11. func NewEsV7Client() (client *elasticsearch.Client, err error) {
  12. conf := elasticsearch.Config{
  13. Addresses: []string{ES_URL},
  14. Username: ES_USERNAME,
  15. Password: ES_PASSWORD,
  16. }
  17. client, err = elasticsearch.NewClient(conf)
  18. return
  19. }