步骤四:业务查询

最近更新时间:2020-03-02 11:18:40

创建索引

在Kibana控制台中,创建一个名称为school的索引,类型为student,包含4个字段,分别是name、address、age和date。关于字段类型说明,可查看官方文档 Field Datatypes 步骤四:业务查询

PUT school
{
  "settings":{
    "number_of_shards": 3,   
    "number_of_replicas": 1 
  },
  "mappings":{
    "student":{
      "properties":{
        "name":{
          "type":"text"
        },
        "address":{
          "type":"keyword"
        },
        "age":{
          "type":"integer"
        },
        "date":{
          "type":"date",
          "format":"yyyy-MM-dd HH:mm:ss"
        }
      }
    }
  }
}

创建文档并插入数据

如果返回显示"errors" : false,说明数据插入成功。 步骤四:业务查询

POST /school/student/_bulk
{"index":{}}
{"name":"张三","address":"山东济南","age":"22","date":"2020-01-19 08:10:00"}
{"index":{}}
{"name":"李四","address":"北京海淀","age":"21","date":"2020-02-19 09:00:00"}
{"index":{}}
{"name":"王五","address":"吉林长春","age":"23","date":"2020-02-19 10:00:00"}

查询数据

步骤四:业务查询

GET /school/_search
{
  "query": {
    "match": {
      "address": "北京海淀"
    }
  }
}

金山云,开启您的云计算之旅

免费注册