Skip to main content

Elastic 维护方法

查看索引

# 使用标准证书访问
curl -v --cacert ./http_ca.crt -u elastic https://localhost:9200/_cat/indices?v

# 跳过证书验证访问
curl -v -k -u elastic https://localhost:9200/_cat/indices?v

删除索引

# 似乎不支持批量删除
curl -X DELETE -k -u elastic "https://localhost:9200/yiling-icc-dev-*"

curl -X DELETE -k -u elastic "https://localhost:9200/yiling-icc-dev-2022-10-25"

为索引指定过期策略

"ilm.policy": "30-days-default"

{
"index": {
"lifecycle": {
"name": "30-days-default"
}
}
}

从 Json 导入数据

refs:

curl -H 'Content-Type: application/json' -XPOST 'localhost:9200/{index}/{type}/{index_name}?pretty' --data-binary @<file_name>.json
curl -H 'Content-Type: application/json' -XPOST 'localhost:9200/{index}/{type}/{index_name}?pretty' -d '{"email_address": "12345678", "phone": "12345678", "qq": "12345678", "message": "12345678", "host": "storage", "@version": "1", "@timestamp": "2023-05-09T22:06:20Z"}'

elasticdump

https://github.com/elasticsearch-dump/elasticsearch-dump

elasticdump \
--input=./qq-phone.json \
--output=http://elastic:[email protected]:30003/qq-phone \
--limit=100000 \
--offset=1139900000
  • limit: 单次导入数量
  • offset: 跳过的数量