当前位置: 首页 > news >正文

ElasticSearch系列---【如何使用curl创建、查看、删除索引?】

ElasticSearch系列---【如何使用curl创建、查看、删除索引?】

1.创建索引

curl -u elastic:elastic_pwd -X PUT http://localhost:9200/suoyinmingcheng -H 'Content-Type:application/json' -d'
{"settings": {"number_of_shards": 5,"number_of_replicas": 1},"mappings": {"properties": {"user": {"type": "keyword"},"message": {"type": "text"},"age": {"type": "integer"},"created_at": {"type": "date","format": "yyyy-MM-dd HH:mm:ss"}}}
}
'

2.查看是否创建成功

curl -u elastic:elastic_pwd -X GET "http://localhost:9200/_cat/indices?v"

3.删除已存在的索引

curl -u elastic:elastic_pwd -X DELETE "http://localhost:9200/suoyinmingcheng"{"settings": {"number_of_shards": 1,"number_of_replicas": 1},"mappings": {"properties": {"user": {"type": "keyword"},"message": {"type": "text"},"age": {"type": "integer"},"created_at": {"type": "date","format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"}}}
}
'