Adding Timestamp to each document added in Elastic

2019-09-06 06:32发布

问题:

How can I create an Index and Mapping with the timestamp field so each added document will include a timestamp by default.

I am using NEST (C#) but I just cant figure out how to do it.

I am also using Kibana but it seems not to work properly because I am missing the timestamp field.

Also, after I am adding this field, is there any way I can 'confirm' the field is added? can I query this field?

Thanks!

回答1:

When you index a document a _timestamp field can be automatically generated for each document.

To enable the timestamp, add the following to your mapping:

{
    "my_mapping" : {
        "_timestamp" : { "enabled" : true, "store" : true }
    }
}