ElasticSearch索引基本常用查询语法入门(kibana)

创建索引

PUT test_index/

创建一个叫test_index的索引

创建mapping

PUT test_index/test01/_mapping
{
  
  
    "test01":{
      "properties":{
        "id":{
          "type":"text"
        },
        "title":{
          "type":"text"
        }
      }
    }
  
  
}

创建test_index索引,type为test01的mapping,properties里装字段的数据类型

text keyword 都是文本类型,text支持分词,可以设置分词,而keyword不支持分词,用来过滤、排序和聚合。加粗样式

可以参考 https://blog.youkuaiyun.com/sunjinjuan/article/details/81986164

通过post上传数据

POST test_index/test01
{
  "id":"aa",
  "title":"bb"
}

通过post请求添加数据到索引为test_index,type为test01中,在代码中我们也可以通过发生post请求来进行增加数据,同时可以配合安全认证shield

在这里插入图片描述
这是增加了一条数据后返回的值,因为,我们上传数据时,没有指定Document,所以这里,生成了一个随机的id

在这里插入图片描述

我们可以通过下面语句来查询
查询单条数据

GET test_index/test01/jVsnEW0BZpThbqaNUwCw
GET 索引/类型/文档

查询所有数据

GET test_index/test01/_search
{"query": {
    "match_all": {}
  }

相当于
GET test_index/test01/_search

查询id为aa的数据,并且只显示title字段

GET test_index/test01/_search
{
  "query": { "match": {
    "id":"aa"
  } },
  "_source": ["title"]
}

在这里插入图片描述

DELETE 索引名

还有许多复杂的查询语句,可以看官方文档

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值