Filter on a datefield relative to today

I have a dataset that includes various date fields, and I would like to only show records where the date is "recent". I can get the data using the date math stuff from the Range Query docs:

GET ipreputation-*/_search
{
    "query": {
        "range" : {
            "status_changed" : {
                "gt" : "now-1d/d",
                "lte" :  "now/d"
            }
        }
    }
}

But how can I do that in the Discover section of Kibana? The Kibana docs are very light on what can go in that query bar.

1 Like

If the time field that you want to filter on ("status_changed") is the one set when you created the index pattern in Kibana, you can filter the Discover or any other section of Kibana by using the timepicker in the upper right of the page.
That has the option to use relative time periods for filtering.

No this has nothing to do with that. This could one of any number of different date fields.
This is about doing the sort of date queries that I described in my original question.

Oh, OK, I understand what you mean now.
There's a solution to that on the Discover field.
You create a pinned filter on the page and then edit it and add your own range math.
To add a filter you expand a document in the Discover field and in the table containing all the fields you can click on the magnifying glass with the plus in to add an "include" filter and the one with the minus to add an "exclude" one.
https://www.elastic.co/guide/en/kibana/current/field-filter.html

1 Like

Oh, that's perfect, thanks. I hadn't spotted that button on the filtered items before.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.