All Documents
Current Document

Content is empty

If you don't find the content you expect, please try another search term

Documentation

Step 4: Query business data

Last updated:2023-07-11 14:20:01

Create an index

In the Kibana console, create the school index of the student type. The index contains four fields: name, address, age, and date. For more information about the field types, see 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"
        }
      }
    }
  }
}

Create a document and insert data

If the returned information contains "errors" : false, the data is inserted.

POST /school/student/_bulk
{"index":{}}
{"name":"Zhangsan","address":"Shandong Jinan","age":"22","date":"2020-01-19 08:10:00"}
{"index":{}}
{"name":"Lisi","address":"Beijing Haidian","age":"21","date":"2020-02-19 09:00:00"}
{"index":{}}
{"name":"Wangwu","address":"Jinlin Changchun","age":"23","date":"2020-02-19 10:00:00"}

Query data

GET /school/_search
{
  "query": {
    "match": {
      "address": "Beijing Haidian"
    }
  }
}
On this page
Pure ModeNormal Mode

Pure Mode

Click to preview the document content in full screen
Feedback