1、深度分页
put方法设置
/demeter_index/_settings
{
"index.max_result_window":20000
}
然后get方法就可以查询到了
/demeter_index/_settings
2、滚动搜索
post方法
/demeter_index/_search?scroll=1m
{
"query":{
"match_all":{}
},
"sort":["_doc"],
"size":5
}
然后新建一个窗口
127.0.0.1:9200/_search/scroll
{"scroll_id": "FGluY2x1ZGVfY29udGV4dF91dWlkDnF1ZXJ5VGhlbkZldGNoAxROZUEtaFhNQjBDWnMzZWFSWVlsbQAAAAAAACZEFk5OdVRaaDlPVER5WlJZQkNVRnZGOEEUTnVBLWhYTUIwQ1pzM2VhUllZbG0AAAAAAAAmRRZOTnVUWmg5T1REeVpSWUJDVUZ2RjhBFE4tQS1oWE1CMENaczNlYVJZWWxtAAAAAAAAJkYWTk51VFpoOU9URHlaUllCQ1VGdkY4QQ==",
"scroll":"1m"
}
3、Es批量操作bulk(查询,新增,修改)
/demeter_index/_doc/_mget
{
"ids":["1001","1002","1021"]
}
批量新增
post方法
127.0.0.1:9200/_bulk
{"create":{"_index":"heiniao55","_type":"_doc","_id":2001}}
{"id":"2001","ProductName":"西瓜"}
{"create":{"_index":"heiniao55","_type":"_doc","_id":2002}}
{"id":"2002","ProductName":"东瓜"}
可以修改一下:抽取公共的
post方法
127.0.0.1:9200/heiniao55/_doc/_bulk
{"create":{"_id":"2005"}}
{"id":"2005","ProductName":"西瓜2"}
{"create":{"_id":"2006"}}
{"id":"2007","ProductName":"东瓜2"}
------------------------------------------------------------------
127.0.0.1:9200/heiniao55/_doc/_bulk
{"index":{"_id":"2015"}}
{"id":"2015","ProductName":"西瓜15"}
{"index":{"_id":"2006"}}
{"id":"2007","ProductName":"东瓜2"}
这里的index 相当于 create和update。有id就更新,没有id就create。
批量更新如下:post方法 127.0.0.1:9200/heiniao55/_doc/_bulk
{"update":{"_id":"2015"}}
{"doc":{"id":"3015","ProductName":"西瓜3015"}}
{"update":{"_id":"2006"}}
{"doc":{"id":"3016","ProductName":"西瓜3016"}}