0

How can I find datetime of last update of the elsasticsearch index? Elasticsearch index last update time I tried to follow the example , but nothing happened .

curl -XGET 'http://localhost:9200/_all/_mapping'
{"haystack":{"mappings":{"modelresult":{"_all":{"auto_boost":true},"_boost":{"name":"boost","null_value":1.0},"properties":{"act_name":{"type":"string","boost":1.3,"index_analyzer":"index_ngram","search_analyzer":"search_ngram"},"django_ct":{"type":"string","index":"not_analyzed","include_in_all":false},"django_id":{"type":"string","index":"not_analyzed","include_in_all":false},"hometown":{"type":"string","boost":0.9,"index_analyzer":"index_ngram","search_analyzer":"search_ngram"},"id":{"type":"string"},"text":{"type":"string","analyzer":"ngram_analyzer"}}},"mytype":{"_timestamp":{"enabled":true,"store":true},"properties":{}}}}}

curl -XPOST localhost:9200/your_index/your_type/_search -d '{
  "size": 1,
  "sort": {
    "_timestamp": "desc"
  },
  "fields": [
    "_timestamp"
  ]
}'
{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":99,"max_score":null,"hits":[{"_index":"haystack","_type":"modelresult","_id":"account.user.96","_score":null,"sort":[-9223372036854775808]}]}}

What is wrong?

Community
  • 1
  • 1

1 Answers1

0

First, what you need to do is to proceed like in that linked question and enable the _timestamp field in your mapping.

{
    "modelresult" : {
        "_timestamp" : { "enabled" : true }
    }
}

Then you can query your index for a single document with the most recent timestamp like this:

curl -XPOST localhost:9200/haystack/modelresult/_search -d '{
  "size": 1,
  "sort": {
    "_timestamp": "desc"
  },
  "fields": [
    "_timestamp"
  ]
}'
Val
  • 207,596
  • 13
  • 358
  • 360