Creating indexes on the fly

When any client tries to index the data for a particular sensor device, it should use the index name with the current day appended in yyyy-mm-dd format after readings. A call to index data for 2019-05-01 would look like the following:

POST /readings-2019-05-01/_doc
{
"sensorId": "a11111",
"timestamp": 1483228800000,
"reading": 1.02
}

When the first record for the date 2019-05-01 is being inserted, the client should use the index name readings-2019-05-01. Since this index doesn't exist yet, and we have an index template in place, Elasticsearch creates a new index using the index template we defined. As a result, the settings and mappings defined in our index template get applied to this new index.

This is how we create indexes based on index templates. In the next section, let's understand why these types of time-based indexes are useful and how to use them in production with your time-series data.

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

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