700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > java操作es创建索引和索引设置

java操作es创建索引和索引设置

时间:2024-02-29 14:00:20

相关推荐

java操作es创建索引和索引设置

1.HttpPost httpPost=HttpPost(ip/索引命/类型命)

2.StringEntity stringEntity = new StringEntity("{空大括号,创建索引时用空大括号}",“UTF-8”)

3.httpPost.setEntity(stringEntity),设置请求体

4.httpPost.setheader(“Content-Type”,“application/json;charet=utf8”),设置请求头

5.CloseableHttpClient httpClient = HttpClientBuilder.create.build(),创建http客户端

6.CloseableHttpResponse response=httpClient.execute(httpPost),放松创建请求

7.创建索引

8.HttpPut httpPut=HttpPut(ip/索引名/_mapping)

9.StringEntity stringEntity = new StringEntity(映射的json,“UTF-8”)

10.剩下的和创建索引一样

11.修改映射

12.HttpPut httpPut=HttpPut(ip/索引名/_settings)

13.StringEntity stringEntity = new StringEntity(修改映射的json,“UTF-8”)

14.剩下的和创建索引一样

15.修改映射

16.{“properties”:{“countryCode”:{“type”:“keyword”}},“createDate”:{“createDate”:{“type”:“keyword”}},“id”:{“id”:{“type”:“keyword”}}},这是映射的json,字段都设置成关键字类型,可以实现中文精确搜索

17.{“index”:{“number_of_replicas”:‘0’}}设置分片数

18.{“index”:{“max_result_window”:‘10000000’}}设置最大查询数量1000w,防止查询时查到的结果集不够

19.ip/端口/index/type/_update_by_query {“script”:{“lang”:“painless”,“source”:"ctx.source[‘属性名称’]=‘需要更新的值’ "},“query”:{“term”:{“属性名称”:“过滤值”}}},可以实现查询更新这样的操作

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。