#ES的文档、索引的CRUD操作
#索引初始化操作
#指定分片和副本的数量
#shards一旦设置不能修改
PUT jobbole
{
"settings":{
"index":{
"number_of_shards":5,
"number_of_replicas":1
}
}
}
GET jobbole/_settings
GET _all/_settings
GET .kibana,jobbole/_settings
GET _settings
# 修改settings
PUT jobbole/_settings
{
"number_of_replicas": 1
}
GET _all
#新增文章
PUT jobbole/job/1
{
"title":"这是一篇文章",
"like":2,
"collect":4,
"comment":6
}
GET jobbole/job/1
GET jobbole/job/1?_source=title,like
GET jobbole/job/1?_source
#修改文章,必须指明ID,覆盖式修改
PUT jobbole/job/1
{
"title":"这是修改后的第一篇文章",
"like":2,
"collect":4,
"comment":6
}
#真正的修改
POST jobbole/job/1/_update
{
"doc":{
"like":66
}
}
#删除
DELETE jobbole/job/1
DELETE jobbole
#查询对应记录
GET _mget
{
"docs":[
{
"_index":"jobbole",
"_type":"job",
"_id":"1"
}
]
}
#查询同一index,同一type中的内容
GET jobbole/job/_mget
{
"docs":[
{
"_id":"1"
}
]
}
GET jobbole/job/_mget
{
"ids":[1]
}
GET jobbole/article/_search
{
"query":{
"match": {
"tags": "Linux"
}
}
}
GET _analyze
{
"analyzer": "ik_smart",
"text": "Java开发工程师"
}
#建立表映射
GET _analyze
{
"analyzer": "ik_smart",
"text": "Java开发工程师"
}
PUT jobbole
{
"mappings": {
"article": {
"properties": {
"title":{
"store": true,
"type": "text",
"analyzer": "ik_max_word"
},
"create_date":{
"type": "date",
"format": "yyyy/MM/dd"
},
"url":{
"type": "keyword"
},
"url_id":{
"type": "keyword"
},
"front_image_url":{
"type": "keyword"
},
"front_image_path":{
"type": "keyword"
},
"like_nums":{
"type": "integer"
},
"collect_nums":{
"type": "integer"
},
"comment_nums":{
"type": "integer"
},
"tags":{
"type": "text"
},
"content":{
"type": "text",
"analyzer": "ik_max_word"
}
}
}
}
}
#插入数据
PUT jobbole/article/2
{
"tltle":"This is My Article.",
"create_date":"2019/1/3",
"url":"none",
"url_id":"none",
"front_image_url":"none",
"front_image_path":"none",
"like_nums":"1";
"collect_nums":"2",
"comment_nums":"3",
"tags":["my","article"],
"content":"The first Acticle."
}
#获取mapping
GET jobbole/_mapping
GET jobbole/_mapping/article