I am attempting to do something, which should be fairly easy. But can't make it happen. Make long story short I use ELK, and Logstash is inserting all the documents for me, with the appropriate filter.
Now I need to insert data to ES manually (via NodeJS), and I have small issue with date type. Ideally I would like to send the timestamp field with the date generated with my NodeJS app and be done with it. The same way Logstash makes an entry. I would love to avoid to set up mappings on the index. I am certain Logstash makes one on the fly, even if there is no index. It makes one.
Well ok, if I have to set my own mapping, then how do I do it?
This is what I have tried so far: Using ElasticSearch for NodeJS
And the code:
saveIndex (lt, gte, indexName) { //lt --> 2018-01-31T12:52:05+01:00 return client.index({ 'index': 'healthcheck', 'type': 'string', 'timestamp': lt, 'body': { 'message': 'Message in a bottle', 'anothertest': 'this is just a test' } }); } When I run that code, my index is created along with the body fields. Works as expected, but I do not have my timestamp value. I expected it gets created automatically. After reading, I saw that I need to create a mapping with a field--> date. And I have done this:
PUT healthcheck { "mappings": { "my_type": { "properties": { "timestamp": { "type": "date", "format": "yyyy-MM-dd" } } } } } After I run this in Kibana I see that I have the timestamp field, but it says it is not Searchable. I deleted the index. Run the mapping statement. Then I have run the code to generate some documents, and still nothing.
What Do I do wrong?