dtp/es/client.go

21 lines
388 B
Go
Raw Normal View History

2024-06-13 13:02:43 +08:00
package es
import (
"fmt"
"github.com/olivere/elastic/v7"
)
func NewElasticSearchClient() (client *elastic.Client, err error) {
client, err = elastic.NewClient(
elastic.SetURL("http://127.0.0.1:9200"),
elastic.SetSniff(false),
elastic.SetBasicAuth("elastic", "Wishpal@2024"),
)
if err != nil {
fmt.Printf("NewElasticSearchClient fail, err: %v", err)
return
}
return
}