golang es设置index max_result_window

这篇具有很好参考价值的文章主要介绍了golang es设置index max_result_window。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

在设置的时候需要对数字使用字符串类型。

{
  "settings": {
    "index": {
      "max_result_window": "1000000000"
    }
  }
}

添加索引名时必须加上"_index"后缀,并且只有在有数据的时候,才能修改成功。

第三方包为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模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • elasticsearch报错:exceeds the [index.highlight.max_analyzed_offset] limit [1000000]

    The length [27277624] of field [content] in doc[2]/index[1234567890abcdefg] exceeds the [index.highlight.max_analyzed_offset] limit [1000000]. To avoid this error, set the query parameter [max_analyzed_offset] to a value less than index setting [1000000] and this will tolerate long field values by truncating them. ********************************************

    2023年04月25日
    浏览(10)
  • MySQL的多层SP中Cursor的m_max_cursor_index相关BUG分析

    MySQL的多层SP中Cursor的m_max_cursor_index相关BUG分析

    在一次开发中在sp中使用多层cursor的时候想知道每层的 m_max_cursor_index 值分别是多少,以用来做后续开发。于是做了以下的试验,但是发现第一个level=2那层的 m_max_cursor_index 的值有点问题。 注:本次使用的MySQL数据库版本为最新的debug版本。 SQL语句示例: 首先查看上面的sp的

    2024年04月08日
    浏览(8)
  • jmeter-results-detail-report_new.xsl文件设置dateReport

    jmeter-results-detail-report_new.xsl文件设置dateReport

    jmeter-results-detail-report_new.xsl文件里设置完成变量后,需要在xsltproc执行时,设置变量 /usr/bin/xsltproc --stringparam dateReport \\\"`date +%Y-%m-%d %H:%M:%S`\\\" /home/jmeter/jmeter5.3/extras/jmeter-results-detail-report_new.xsl    

    2024年02月12日
    浏览(8)
  • ES-index索引配置

      index索引配置项使用。 index_options   Index 有4中配置,可以控制倒排索引的内容。   Text类型默认记录positions,其他默认docs。记录的内容越多,所占用的空间越大。   Index 有4中配置如下: docs   记录 doc id 。 freqs   记录 doc id 和 term frequencies 。 positions   记录

    2023年04月08日
    浏览(9)
  • 查看ES的index生成时间

    查看ES的index生成时间

    直接开启kibana,输入以下命令: 从返回的结果中,找到creation_date,如下: 即可获取到该索引创建的时间。 分享这个,其实是因为线上确定问题时用得到,特别是es的索引结构是可以自动创建的,很多时候,你索引给人删除了,但是只要有数据进去,索引又会被重新创建出来

    2024年02月15日
    浏览(10)
  • MVC 字符串的长度超过了为 maxJsonLength 属性设置的值 重写result

    报错信息: 字符串的长度超过了为 maxJsonLength 属性设置的值 该属性在system.mvc.jsonresult里,但是没有给他设置值,所以他应该是默认值很小。 想重写这个jsonresult,给这个属性赋一个最大值,就比较稳妥 重写方法: 这里我本来没写构造函数,直接调父类得MaxJsonLength 属性,发

    2024年02月12日
    浏览(7)
  • ES 安装、search、index、doc

    ES 安装、search、index、doc

    https://www.elastic.co/cn/ 下载 https://www.elastic.co/cn/downloads/past-releases/elasticsearch-8-5-3 https://www.elastic.co/cn/downloads/past-releases/kibana-8-5-3 解压,点击 D:elasticsearch-8.5.3binelasticsearch.bat 启动后会报错 修改配置 \\\"D:elasticsearch-8.5.3configelasticsearch.yml\\\" 配置文件会多出来一些配置 学习环境下

    2024年02月06日
    浏览(7)
  • 解决ES search.max_buckets参数问题

    解决ES search.max_buckets参数问题

    Trying to create too many buckets. Must be less than or equal to: [65535] but was [65536]. This limit can be set by changing the [search.max_buckets] cluster level setting. 临时 解决办法: 或者   -------------------------------------------------------------------------------------------------------------------------------- 永久 解决方法:  或

    2024年02月11日
    浏览(7)
  • ES 10 - 如何使用Elasticsearch的索引模板(index template)

    本文转载自:ES 10 - 如何使用Elasticsearch的索引模板(index template) - 瘦风 - 博客园 索引模板: 就是把已经创建好的某个索引的参数设置(settings)和索引映射(mapping)保存下来作为模板, 在创建新索引时, 指定要使用的模板名, 就可以直接重用已经定义好的模板中的设置和映射. (1) sett

    2024年02月15日
    浏览(11)
  • ES之API系列--index template(索引模板)的用法(有实例)

    ES之API系列--index template(索引模板)的用法(有实例)

    原文网址:ES之API系列--index template(索引模板)的用法(有实例)_IT利刃出鞘的博客-CSDN博客 说明 本文介绍ElasticSearch的index template(索引模板)的用法(有实例)。 官网网址 https://www.elastic.co/guide/en/elasticsearch/reference/8.0/index-templates.html 作用概述         在 新建 索引时,如果索引名

    2024年04月09日
    浏览(20)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包