1,基本概念
elasticsearch本质也是存储数据。
索引(indices)---Databases数据库(indices是index的复数,代表多的索引)
类型(type)---Table数据库
文档(Document)---Row 行(存入索引库原始的数据,比如一条用户信息,就是一个文档)
字段(Field)----Columns列(文档中的属性)
映射配置(mappings)---字段的数据类型,属性,是否索引,是否存储等特性
索引集(indices,index的复数):逻辑上的完整索引collection1
分片(shard):数据拆分后的各部分
副本(replica):每个分片的复制
<<Elasticsearch: 权威指南>>:https://www.elastic.co/guide/cn/elasticsearch/guide/current/getting-started.html
图画理解Elasticsearch:https://developer.51cto.com/art/201904/594615.htm
2,创建索引
Elasticsearch采用Rest风格API,所以API就是一次http请求,可用任何工具发起http请求创建索引。
请求方式:PUT
请求路径:/索引库名
请求参数:json格式:
{
"settings":{
"number_of_shards":1, //分片
"number_of_replicas":0 //副本
}
}
例:
PUT /hh
{
"settings": {
"number_of_shards":1,
"number_of_replicas":0
}
}
3,查看索引:
GET /索引库名
4,删除索引:
DELETE /索引库名