Q:

can a relative date query can be performed on Solr

I'm working with Solr data sets. I'm thinking is there a way through which I can query(date query) such that it's is relative to each record date field 
To explain it further..
Each record has a date field all I need is a list of all records whose date has passed the 30-minute window.
Just to how to 
I have a JSON structure of form and I have applied indexes on created_at 
{id: 1, created_at: "2018-06-28T:00:00:00Z"}
{id: 2, created_at: "2018-06-28T:00:01:00Z"}
{id: 3, created_at: "2018-06-28T:00:02:00Z"}
{id: 4, created_at: "2018-06-28T:00:10:00Z"}

Let's say If I'm querying at 00:33 I would return 3 records.
{id: 1, created_at: "2018-06-28T:00:00:00Z"}
{id: 2, created_at: "2018-06-28T:00:01:00Z"}
{id: 3, created_at: "2018-06-28T:00:02:00Z"}

and If I query at 00:41 it should return 4 records.
{id: 1, created_at: "2018-06-28T:00:00:00Z"}
{id: 2, created_at: "2018-06-28T:00:01:00Z"}
{id: 3, created_at: "2018-06-28T:00:02:00Z"}
{id: 4, created_at: "2018-06-28T:00:10:00Z"}

To explain this further. If I have to do the same in PostgreSQL I can try this.
select * from [table] where now() - created_at > interval '30 minute'

A:

Solr supports using Date Math in queries. 
To retrieve anything where created_at is at least 30 minutes ago, you can use:
created_at:[* TO NOW-30MINUTES]

This will return anything that was created at least 30 minutes ago. Using NOW means the query won't be cached (since the value of NOW changes between each request), so if this is a query that's run many times each second, you can pregenerate those values in your controller before Solr sees the values, or you can use the query parameter NOW=<unix timestamp> to set a common value across all request. Another option is to use NOW/MINUTE to round the value to the beginning of the current minute instead.
To get everything that's in the past (which was what your previous query example indicated, but the postgresql query didn't):
created_at:[* TO NOW]

