golang操作elasticsearch详解
golang操作elasticsearch详解
直接上代码
package main
import (
"bytes"
"context"
"fmt"
"github.com/olivere/elastic/v7"
"log"
)
const IndexName = "test_index"
func main() {
IsDocExists("xxx", IndexName)
}
//获取Es客户端
func GetEsClient() *elastic.Client {
var buf bytes.Buffer
client, err := elastic.NewClient(
elastic.SetURL("http://127.0.0.1:9200/"),
//docker
elastic.SetSniff(false),
elastic.SetIn
共有 0 条评论