Delete by query with dynamic values


(vannya) #1

Hi all,

And wondering if I could do something like:

curl -XDELETE 'http://localhost:9200/my_index/my_type/_query?
q=creationDate:[* TO now-interval]'

in which "now" should dynamically represent the timestamp of query
execution and "interval" a date like "1d".

With this, I want to implement a process that executes a delete by
query of all documents in which creationDate is 1 day older than the-
moment-of-query-execution (kinda aging).

Thanks in advance!


(Karussell) #2

Have a look at TimeToLive:

http://www.elasticsearch.org/guide/reference/mapping/ttl-field.html

I think date math like in Solr is not supported directly in ES. Only
via scripting:

http://www.elasticsearch.org/guide/reference/modules/scripting.html

Peter.

On 11 Jan., 13:29, vannya vann...@gmail.com wrote:

Hi all,

And wondering if I could do something like:

curl -XDELETE 'http://localhost:9200/my_index/my_type/_query?
q=creationDate:[* TO now-interval]'

in which "now" should dynamically represent the timestamp of query
execution and "interval" a date like "1d".

With this, I want to implement a process that executes a delete by
query of all documents in which creationDate is 1 day older than the-
moment-of-query-execution (kinda aging).

Thanks in advance!


(vannya) #3

Hi Karussel, thanks for your reply!

Yes, I already knew ttl, but is not exactly what I'm looking (I need
to set the interval as an regular expression, and be able to change
ttl at any time and see the change reflected in all indexed
documents)...

Thanks!

On Jan 11, 12:53 pm, Karussell tableyourt...@googlemail.com wrote:

Have a look at TimeToLive:

http://www.elasticsearch.org/guide/reference/mapping/ttl-field.html

I think date math like in Solr is not supported directly in ES. Only
via scripting:

http://www.elasticsearch.org/guide/reference/modules/scripting.html

Peter.

On 11 Jan., 13:29, vannya vann...@gmail.com wrote:

Hi all,

And wondering if I could do something like:

curl -XDELETE 'http://localhost:9200/my_index/my_type/_query?
q=creationDate:[* TO now-interval]'

in which "now" should dynamically represent the timestamp of query
execution and "interval" a date like "1d".

With this, I want to implement a process that executes a delete by
query of all documents in which creationDate is 1 day older than the-
moment-of-query-execution (kinda aging).

Thanks in advance!


(system) #4