5.ElasticSearch关于索引的基本操作

基础测试

5.1.创建一个索引

PUT /索引名/~类型名~/文档id
{
	请求体
}
PUT /test1/type1/1
{
	"name":"zjzaki",
	"age":"5"
}

image-20230228105221320

image-20230228105521180

5.2.数据类型

  • 字符串类型 text、keyword
  • 数值类型 long,integer,short,double,float,half float,scaled float
  • 日期类型 date
  • 布尔值类型 boolean
  • 二进制类型 binary
  • 等等

指定字段的类型

PUT /test2
{
	"mappings": {
		"name":{
			"type": "text"
		},
		"age":{
			"type": "long"
		},
		"birthday": {
			"type": "date"
		}
	}
}

image-20230228110112814

获得这个规则!可以通过get请求得到具体的信息

GET test2

image-20230228110304639

5.3.查看默认的信息

PUT /test3/_doc/1
{
	"name": "zjzaki",
	"age": "5",
	"birthday": "1999-10-1"
}

image-20230228110555237

如果自己的文档字段没有指定,那么es就会给我们默认配置字段类型

5.4.扩展:通过命令 elasticsearch 索引情况!

GET _cat/health

image-20230228111156848

GET _cat/indices?v

image-20230228111249409

5.5.修改索引 提交还是使用put 然后覆盖 --- 以下新办法

POST /test3/_doc/1/_update

image-20230228111834098

5.6.删除索引

DELETE test1

image-20230228112008224