Step 4: Query business data

Last updated:2020-12-28 14:51:02

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"
    }
  }
}

Did you find the above information helpful?

Unhelpful
Mostly Unhelpful
A little helpful
Helpful
Very helpful

What might be the problems?

Insufficient
Outdated
Unclear or awkward
Redundant or clumsy
Lack of context for the complex system or functionality

More suggestions

0/200

Please give us your feedback.

Submitted

Thank you for your feedback.

问题反馈