Hi team,
I am writing to ask: What is the best way to construct a query to satisfy the following requirement: Date range specification in the filter
clause of a boolean
query so that gte
is based on the oldest document in the index.
Consider:
...
"filter":
{
"range":
{
"CustomElasticSearchDateTime":
{
"gte": "OLDEST DOCUMENT", <-- (How to get the oldest document here based on the index being searched?)
"lte": "OLDEST DOCUMENT + 6M/M",
"relation": "WITHIN"
}
}
}
...
Here is how I am currently get the oldest document from the index:
{
"size": 1,
"_source": false,
"sort":
{
"CustomElasticSearchDateTime": "asc"
},
"query":
{
"match_all": {}
}
}
But it does not seem possible to add this query under the gte
of the previous query; or, is it possible. Any help here would be much appreciated.
Thank you