Elasticsearch delete a document based on a field value -


i new elasticsearch , trying figure out way delete document contains field timestamp value.

i have document field called lastmodifiedtime. field of type long , being used store timestamp (i.e number of milliseconds since epoch. ex, 1486709502).

now have usecase need delete documents having lastmodifiedtime older 1 day. find out timstamp value corresponding 1 day older time , try delete documents.

i tried rest call below

delete http://localhost:9200/testindex/testtype/_query "query": {     "term" : {         "lastmodifiedtime" : {         "lte": 1486709504         }     }  } 

but getting following response:

{     "found": false,     "_index": "testindex",     "_type": "testtype",     "_id": "_query",     "_version": 4,     "result": "not_found",     "_shards":     {         "total": 2,         "successful": 1,         "failed": 0     } } 

could please me how deal scenario?

you can use delete_by query api

post http://localhost:9200/testindex/testtype/_delete_by_query {   "query": {     "range": {       "lastmodifiedtime": {         "lte": 1486709504       }     }   } } 

thanks


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -