elasticsearch增删改语句模板

来源:互联网 发布:房子平面设计软件手机 编辑:程序博客网 时间:2024/06/18 08:14
POST _bulk{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }{ "field1" : "value1" }{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }{ "create" : { "_index" : "test", "_type" : "type1", "_id" : "3" } }{ "field1" : "value3" }{ "update" : {"_id" : "1", "_type" : "type1", "_index" : "test"} }{ "doc" : {"field2" : "value2"} }

在项目中使用的实例:

POST worksheet*/_bulk{"update": { "_id": "9538C7DC36C44ECE92499F0D79F298A1", "_type": "trans", "_index": "worksheet2017-10" }}{"doc": {"manualData": { "isAssigned": "测试你", "inspectorId": "ff8080815e170ce1015e18032c4d0067", "inspectorName": "11", "assignTime": "2017-10-18 21:31:24" }}}

注意在拼接字符串的时候 update语句后面一定要加上换行符号  \n


这是基于kibana在RESTful下发送命令。

在项目中直接通过发送http请求实现数据的修改

HTTPMethod.doPostQuery("http://10.0.1.128:9200/worksheet" + "/_bulk", bulk.toString(), 30000);

详情网站:

https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html


原创粉丝点击