1 Star 1 Fork 0

宇宙蒙面侠X / github.com-olivere-elastic

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
connect_with_config.go 1.06 KB
一键复制 编辑 原始数据 按行查看 历史
Oliver Eilhard 提交于 2018-08-28 10:09 . Revert changes to import path
// Copyright 2012-present Oliver Eilhard. All rights reserved.
// Use of this source code is governed by a MIT-license.
// See http://olivere.mit-license.org/license.txt for details.
// Connect simply connects to Elasticsearch.
//
// Example
//
//
// connect "http://127.0.0.1:9200/test-index?sniff=false&healthcheck=false"
//
package main
import (
"flag"
"fmt"
"log"
"runtime"
"github.com/olivere/elastic"
"github.com/olivere/elastic/config"
)
func main() {
flag.Parse()
log.SetFlags(0)
url := flag.Arg(0)
if url == "" {
url = "http://127.0.0.1:9200"
}
// Parse the URL with the config package
cfg, err := config.Parse(url)
if err != nil {
log.Fatal(err)
}
// Create an Elasticsearch client
client, err := elastic.NewClientFromConfig(cfg)
if err != nil {
log.Fatal(err)
}
// Get ES version
esversion, err := client.ElasticsearchVersion(cfg.URL)
if err != nil {
log.Fatal(err)
}
// Just a status message
fmt.Printf("Connection succeeded with %v, Elastic %v and Elasticsearch %s\n",
runtime.Version(),
elastic.Version,
esversion,
)
}
1
https://gitee.com/awol2010ex/github.com-olivere-elastic.git
git@gitee.com:awol2010ex/github.com-olivere-elastic.git
awol2010ex
github.com-olivere-elastic
github.com-olivere-elastic
v6.2.37

搜索帮助