21 lines
388 B
Go
21 lines
388 B
Go
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
|
|
}
|