Defining an index template

We start by defining an index template:

PUT _template/readings_template                 1
{
"index_patterns": ["readings*"], 2
"settings": { 3
"number_of_shards": 1
},
"mappings": { 4
"properties": {
"sensorId": {
"type": "keyword"
},
"timestamp": {
"type": "date"
},
"reading": {
"type": "double"
}
}
}
}

In this _template call, we define the following things:

  • A template with the name readings_template.
  • The index name patterns that will match this template. We configured readings* as the one and only index pattern. Any attempt to index into an index that does not exist but matches this pattern would use this template.
  • The settings to be applied to the newly created index from this template.
  • The mappings to be applied to the newly created index from this template.

Let's try to index data into this new index.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset