1

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?

1 Answer 1

1

I think you need to write the mapping so that the field will be indexed.

https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-index.html

(It says that true is default but it also says that if it's not than it's not searchable, so that's my best guess)
Alternatively you can try the quick solution (not a guaranteed fix) and in Kibana go to management/index patterns/your index pattern and in the top right corner hit the refresh button. That should index it for you.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.