1.创建索引
curl -XPUT ip:port/index_name -H "Content-Type: application/json" -d '{"settings": {"number_of_replicas":0,"number_of_shards":3,"refresh_interval":"-1","index.mapping.total_fields.limit":100}}'
指定0个备份,3个分片,不更新索引,字段最多100个
2.导入数据
大部分可以用datax,也可以手写bulk api。
3.修改索引
curl -XPUT ip:port/index_name -H "Content-Type: application/json" -d '{"settings": {"refresh_interval": "5s","number_of_replicas":1}}'
修改索引更新时间间隔为5秒,备份数为1
4.分页查询(scroll)
首页(返回scroll_id用于翻页)
curl -XPOST -H "Content-Type: application/json" ip:port/index_name/_search?scroll=1m -d '{"size": 3}'
指定scroll_id过期时间为1分钟,每页返回3条数据。
2-尾页
curl -XGET ip:port/_search/scroll?scroll=1m&scroll_id=...
尾页再次向下翻页返回"hits":[]
5.删除索引
curl -XDELETE ip:port/index_name