Query data

Last updated:2022-01-11 13:43:17

Create an index

In the Kibana console, create an index named school with a type named student. Create the following four fields for this index: name, address, age, and date. For more information about field types, see the official document Field Datatypes.
image.png

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 “errors” : false is returned, data is successfully inserted.
image.png

POST /school/student/_bulk
{"index":{}}
{"name":"Zhang San","address":"Jinan, Shandong","age":"22","date":"2020-01-19 08:10:00"}
{"index":{}}
{"name":"Li Si","address":"Haidian District, Beijing","age":"21","date":"2020-02-19 09:00:00"}
{"index":{}}
{"name":"Wang Wu","address":"Changchun, Jilin","age":"23","date":"2020-02-19 10:00:00"}

Query data

image.png

GET /school/_search
{
  "query": {
    "match": {
      "address": "Haidian District, Beijing
    }
  }
}

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.

问题反馈