1.查看索引库的mapping
GET /my_index/my_type/_mapping
2.查看索引库的数据
GET /my_index/my_type/_search
3.es中创建后的mapping不可修改,但是可以添加新字段
PUT /my_index/_mapping/my_type
{
"properties": {
"new_field_name": {
"type": "keyword"
}
}
}
赋值:
POST my_index/_update_by_query
{
"script": {
"lang": "painless",
"inline": "ctx._source.new_field_name= '02'"
}
}
4.删除索引库
DELETE my_index
5. 分页查询,默认情况下查询一页十条数据
POST /_search
{
"size": 2,
"from": 10,
"query": {
"match_all": {}
}
}
size:表示每页显示多少条记录,form:表示从第几页开始显示记录
6.使用ik分词器分词
POST _analyze
{
"analyzer": "ik_max_word",
"text": "中国银行"
}
7.更新索引库中某个字段的值、
POST my_index/_update_by_query
{
"script": {
"lang": "painless",
"inline": "if(ctx._source.title== '李四'){ctx._source.title= '张三'}"
}
}
注释:将索引库my_index里面字段title值为李四的改为张三
8.直接向索引库添加数据
PUT /my_index/my_type/5
{
"title": "中国",
"content": "中国银行"
}