赞
踩
查看索引
curl 127.0.0.1:9200/_cat/indices
请求
curl 127.0.0.1:9200/_cat
可获取用于查询的名称
创建索引
索引可以在添加文档数据时,通过动态映射的方式自动生成索引与类型。
索引也可以手动创建,通过手动创建,可以控制主分片数目、分析器和类型映射。
- PUT /my_index
- {
- "settings": { ... any settings ... },
- "mappings": {
- "type_one": { ... any mappings ... },
- "type_two": { ... any mappings ... },
- ...
- }
- }
注: 在Elasticsearch 5.x版本中,设置分片与设置索引的类型字段需要分两次设置完成。
删除索引
用以下的请求来 删除索引:
DELETE /my_index
你也可以这样删除多个索引:
- DELETE /index_one,index_two
- DELETE /index_*
你甚至可以这样删除 全部 索引:
- DELETE /_all
- DELETE /*
创建头条项目文章索引库
- // 文章索引
- curl -X PUT 127.0.0.1:9200/arti
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。