restful 对索引的操作(讲解用 postman 操作)
head创建索引
默认分片数5 备份1 粗边框是主分片 细边框为粗边框的备份分片
mapping 结构化分片区分
请求地址:
http://127.0.0.1:9200/book/novel/_mapping索引/类型/文档id
请求方式:POST
创建索引直接请求api接口
http://127.0.0.1:9200/people索引
请求方式:PUT
参数:settings关键词 指定分片数 和备份
可以使用“||”定义多种类型
1、RESTFul API
基本格式:<http://><ip>:<port>/index/type/id
常用http动词:GET/PUT/POST/DELETE
2、创建索引:
PUT方法
索引结构:(json)
{
"setting":{
"number_of_shards": 5
"number_of_replicas": 1
}
"mappings": {
"novel":{
"propperties":{
"title":{
"type":"text"
}
}
}
}
}
}
1、RESTFul API
基本格式:<http://><ip>:<port>/index/type/id
常用http动词:GET/PUT/POST/DELETE
2、创建索引:
PUT方法
索引结构:(json)
{
"setting":{
"number_of_shards": 5
"number_of_replicas": 1
}
"mappings": {
"novel":{
"propperties":{
"title":{
"type":"text"
}
}
}
}
}
}
1、RESTFul API
基本格式:http://ip:port/index/type/id
常用http动词:GET/PUT/POST/DELETE
2、创建索引:
PUT方法
索引结构:(json)
{
"setting":{
"number_of_shards": 5
"number_of_replicas": 1
}
"mappings": {
"novel":{
"propperties":{
"title":{
"type":"text"
}
}
}
}
}
}
1、RESTFul API
基本格式:http://ip:port/index/type/id
常用http动词:GET/PUT/POST/DELETE
2、创建索引:
PUT方法
索引结构:(json)
{
"setting":{
"number_of_shards": 5
"number_of_replicas": 1
}
"mappings": {
"novel":{
"propperties":{
"title":{
"type":"text"
}
}
}
}
}
}
api基本格式
创建索引
非结构化创建
结构化创建
mappinng 是否为空,如果为空,则为非结构化创建
elasticsearch
索引相当于数据库,分片相当于把一个数据库分开成多个,方便数据量大的时候的操作,分片只能创建索引时修改,备份可以随时修改
类型相当于表
文档相当于每条记录
restful api
api 基本格式,
设置结构化
索引信息就会显示出来
postman 形式
粗线框是主分片,细线框是分片的备份
细框是粗框的备份分片。
非结构化与结构化的区分:mappings 是否为空
7.12.0支持的写法, 不再支持两个man和women, 也不再支持man这种定义, 默认为_doc
// 实际发现并不需求这样做, 如视频这样做, 很可能会报错, 直接插入记录就好, es会自动实现mappings
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1
},
"mappings": {
"properties": {
"name": {
"type": "text"
},
"contry": {
"type": "keyword"
},
"age": {
"type": "integer"
},
"date": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
}
}
}
}
{ "novel":{ "properties":{ "title":{ "type":"text" } } } }
索引还有结构化和非结构化之分吗
貌似不是我理解的整齐性,而是有没有内部体系的映射
每个索引信息里都应该包含一个mappings
RESTFul API
restful api接口方法:
get:获取信息 ,
post:新建或更新信息,
put:存储信息,
delete:删除信息
用postman创建索引:
创建非结构化索引:
非结构化索引信息查看:
结构化索引判断标志:
api格式
用Head 创建类型,类型名:novel
url:
book/novel/_mapping
body:
{
"novel": {
"properties": {
"title": {
"type": "text"
}
}
}
}
RestFul API基本格式
用post man创建索引
http verb: put
url:
localhost:9200/people
body:
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1
},
"mappings": {
"man": {
"properties": {
"name": {
"type": "text"
},
"age": {
"type": "integer"
},
"contry": {
"type": "keyword"
},
"date": {
"type": "date",
"format": "yyyyMMdd HH:mm:ss||yyyyMMdd||epoch_millis"
}
}
}
}
}
API基本格式
post 127.0.0.1:9200/people 报没有post方法,postman改为put提交就成功了
这里只能在第一次的基础上添加,而不能修改