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”:{“属性名称”:“过滤值”}}},可以实现查询更新这样的操作

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐