一、索引
1、创建索引
- 请求方式:PUT
- 请求路径:索引库名
- 请求参数:json格式
PUT goods
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
}
}
settings: 索引库的设置
number_of_shards:分片数量
number_of_replicas:副本数量
2、查看索引
GET goods
结果:
{
"goods": {
"aliases": {},
"mappings": {},
"settings": {
"index": {
"creation_date": "1576352109034",
"number_of_shards": "1",
"number_of_replicas": "0",
"uuid": "Gj7xO8mWR7qJTLveA7s73Q",
"version": {
"created": "6020499"
},
"provided_name": "goods"
}
}
}
}
3、查询所有索引
GET *
4、删除索引
DELETE goods
二、映射
映射是定义文档的过程,文档包含哪些字段,这些字段是否保存,是否索引,是否分词等
1、创建映射字段
PUT goods/_mapping/course
{
"properties": {
"title": {
"type": "text",
"analyzer": "ik_max_word"
},
"images": {
"type": "keyword",
"index": false
}
}
}
2、查看映射关系
GET goods/_mapping
-- 结果 --
{
"goods": {
"mappings": {
"course": {
"properties": {
"images": {
"type": "keyword",
"index": false
},
"title": {
"type": "text",
"analyzer": "ik_max_word"
}
}
}
}
}
}