You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE] Support earliest and latest in search command #4135
Currently, earliest and latest options are supported in conditions (doc) and aggregation functions (#4100), but not yet supported in search command. E.g. search source=emps earliest=-1d
What solution would you like?
Support earliest and latest parameter in search command
With #4152 , we will push down all search options as query string queries.
I found that OpenSearch already supports relative time in query string queries (and other queries like range query and match query). E.g. GET time_test/_search
Supported formats include (compared with our expectation in the description):
Absolute time: 2099-12-01T23:59:59.999999999Z
Relative time: now-30s, now+1h
Keyword: now
Keyword combined with modifier: (already exemplified)
Implicit time with alignment: now-1h/d (an hour in the past round down to day)
What is not supported is week reference like @w0.
Should we favor this format over the format stated in the description as this is a query language for OpenSearch? Or is it better to stick with the described representation like -1h@d. cc @penghuo@LantaoJin
In this way, we can easily push down the time modifiers without defining a new grammar.
As an alternative, it is also totally OK to convert the described time reference format to OpenSearch's reference format.
Update: the latest implementation still uses the PPL grammar. The underlying implementation translates them to OpenSearch date math expressions.
Activity
yuancu commentedon Sep 10, 2025
I encountered a design decision dilemma.
With #4152 , we will push down all search options as query string queries.
I found that OpenSearch already supports relative time in query string queries (and other queries like range query and match query). E.g. GET time_test/_search
{ "query": { "query_string": { "query": "timestamp:[* TO now-1d/d]" } } }Supported formats include (compared with our expectation in the description):
2099-12-01T23:59:59.999999999Znow-30s,now+1hnownow-1h/d(an hour in the past round down to day)What is not supported is week reference like
@w0.Should we favor this format over the format stated in the description as this is a query language for OpenSearch? Or is it better to stick with the described representation like
-1h@d. cc @penghuo @LantaoJinIn this way, we can easily push down the time modifiers without defining a new grammar.
As an alternative, it is also totally OK to convert the described time reference format to OpenSearch's reference format.
Update: the latest implementation still uses the PPL grammar. The underlying implementation translates them to OpenSearch date math expressions.