kibana维护elasticsearch时常用操作指令

创建索引:

格式如下:

PUT /索引名称
{
  “settings”: { 配置信息},
  “mappings”: {
     “type名称”: {

      "properties": { 

         “字段”:{"type":“字段类型”}

       .......
      }
   }
}

示例:

PUT /test_index
{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0
  },
  "mappings": {
    "test_type": {
      "properties": {
        "count": {
          "type": "integer"
        },
        "title": {
          "type": "keyword"
        },
        "content": {
          "type": "text"
        },
        "createTime": {
          "type": "text"
        }
      }
    }
  }
}

修改索引:

PUT /索引/type名称/_mapping
{
  "type名称": {
    "properties": {
         “字段”:{"type":“字段类型”}

       ......
    }
  }
}

示例:

PUT /test_index/test_type/_mapping
{
  "test_type": {
    "properties": {
      "count": {
        "type": "integer"
      },
      "title": {
        "type": "keyword"
      },
      "content": {
        "type": "text"
      }
    }
  }
}
 

数据插入 :

格式:

POST /索引/type名称
{
  ...数据内容...
}

示例

POST /test_index/test_type
{
  "count": 10,
  "title": "测试标题",
  "content": "这是一个测试"
}

 

数据修改:

格式:

PUT /索引/type名称/数据的id
{
  ...数据内容...
}

示例

PUT /test_index/test_type/psWo_XIBgk8NUD3GDq9p
{
  "count": 10,
  "title": "测试标题",
  "content": "这是一个测试(添加修改)"
}

删除:

删除响应文档  

格式: DELETE /索引名称/type名称/数据的id

示例: DELETE /test_index/test_type/uqb_-HIBu2vUiLQfN6wu

删除所有索引 DELETE /_all

查询:

根据字段模糊查询(注意安装中文分词器): 

格式: 

GET /_search{

"query": {
        "match" : {
            "字段" : "字段值(可模糊匹配)"
        }
    }

}

示例:

GET /_search
{
  "query": {
        "match" : {
            "content" : "测试"
        }
    }
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值