索引操作

1 查看索引的mapping结构

GET http://ip:port/index/_mapping

2 索引的mapping结构中添加字段

a)增加字段 sourceType,类型为keyword。keyword与text的区别为:keyword在查找时不分词,完全匹配地查找。

PUT http://ip:port/index/_mapping

{
  "properties": {
    "sourceType": {
      "type": "keyword"
    }
  }
}

 

3 条件删除索引中的数据

POST http://ip:port/index/_delete_by_query

{
  "query": { 
    "match": {
      "field": "xxx"
    }
  }
}

删除某个索引中的全部数据

{
  "query": {
    "match_all": {}
  }
}

 

4 向某个索引中新建增一条数据

POST http://ip:port/index/ 

json参数根据index的mapping结构即可。例如

{
    "name": "zhangsan",
    "address": "beijing"
}

 

posted @ 2020-09-08 18:05  江湖凶险  阅读(81)  评论(0编辑  收藏  举报