elasticsearch索引

查看集群状态
http://127.0.0.1:9200/_cluster/health

返回:
{"cluster_name":"elasticsearch","status":"green","timed_out":false,"number_of_nodes":3,"number_of_data_nodes":3,
"active_primary_shards":45,"active_shards":90,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":0,
"delayed_unassigned_shards":0,"number_of_pending_tasks":0,"number_of_in_flight_fetch":0,
"task_max_waiting_in_queue_millis":0,"active_shards_percent_as_number":100.0}


查询所有索引:
http://172.0.0.1:9200/_cat/indices

 

 查看单个索引:

http://172.0.0.1:9200/index_name
或者:http://172.0.0.1:9200/_mapping/索引别名

3、创建索引:
put请求 http://127.0.0.1:9200/索引名称

body 参数

{
"mappings":{
"properties":{
"realname":{
"type":"text",
"index":true
},
"username":{
"type":"keyword",
"index":false
}
}
}
}

mappings properties 为固定结构

realname username 相当于数据库中的 列 type 为数据类型 index是否支持索引
其中 text keyword 是数据类型 都属于 string类型 但是 keywrod不支持倒排索引 只支持精确查找

创建成功返回消息

{"acknowledged":true,"shards_acknowledged":true,"index":"index_mapping"}



1、 #删除指定索引 # curl -XDELETE -u elastic:changeme http://localhost:9200/acc-apply-2018.08.09 {"acknowledged":true} 2、#删除多个指定索引,中间用逗号隔开 # curl -XDELETE -u elastic:changeme http://localhost:9200/acc-apply-2018.08.09,acc-apply-2018.08.10 3、#模糊匹配删除 # curl -XDELETE -u elastic:changeme http://localhost:9200/acc-apply-* {"acknowledged":true} 4、#使用通配符,删除所有的索引 curl -XDELETE http://localhost:9200/_all 或 curl -XDELETE http://localhost:9200/* _all ,* 通配所有的索引 通常不建议使用通配符,误删了后果就很严重了,所有的index都被删除了 禁止通配符为了安全起见,可以在elasticsearch.yml配置文件中设置禁用_all和*通配符 action.destructive_requires_name = true 这样就不能使用_all和*了  5、#获取当前索引 # curl -u elastic:changeme 'localhost:9200/_cat/indices?v'

 

posted @ 2020-04-26 16:56  凉城  阅读(233)  评论(1编辑  收藏  举报