在设置的时候需要对数字使用字符串类型。
{
"settings": {
"index": {
"max_result_window": "1000000000"
}
}
}
添加索引名时必须加上"_index"后缀,并且只有在有数据的时候,才能修改成功。文章来源:https://www.toymoban.com/news/detail-518399.html
第三方包为github.com/olivere/elastic/v7。文章来源地址https://www.toymoban.com/news/detail-518399.html
var AddrOption = func(adds []string) elastic.ClientOptionFunc {
return elastic.SetURL(adds...)
}
var AuthOption = func(username, password string) elastic.ClientOptionFunc {
return elastic.SetBasicAuth(
username, //账号
password, //密码
)
}
var InfoLogOption = func() elastic.ClientOptionFunc {
return elastic.SetInfoLog(log.New(os.Stdout, "", log.LstdFlags)) //INFO级别日志输出配置
}
func newConn(options ...elastic.ClientOptionFunc) *elastic.Client {
options = append(options,
elastic.SetSniff(false),
elastic.SetHealthcheck(true),
elastic.SetHealthcheckInterval(30*time.Second),
)
con, err := elastic.NewClient(options...)
if err != nil {
panic(err)
}
return con
}
var globalClient *Client
type Client struct {
conn *elastic.Client
}
func NewEsClient(options ...elastic.ClientOptionFunc) *Client {
if globalClient == nil {
globalClient = &Client{conn: newConn(options...)}
}
return globalClient
}
const (
idx = "this_is_a_test_index"
)
func es() {
......
ctx := context.Background()
c := NewEsClient(AddrOption (strings.Split("http://192.168.0.2:59201", ",")), InfoLogOption(), AuthOption("elastic", "qd12Qs341"))
doc := elastic.NewBulkUpdateRequest().
Index(idx).
Id((uuid.New()).String()).
Doc(string(data)).
DocAsUpsert(true)
c.conn.Bulk().Add(doc).Do(ctx)
c.conn.Search().Index(idx).TrackTotalHits(true).Do(ctx)
c.conn.IndexPutSettings(idx).BodyString(`{
"settings": {
"index": {
"max_result_window": "1000000000"
}
}
}
`).Do(ctx)
}
到了这里,关于golang es设置index max_result_window的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!