Apply aggregation result to values in the document [Elasticsearch]

so what I'm trying to do is change the actual values in the document depending on the aggregation result, I'm not sure if this is possible or not but here are some examples to what I'm trying to do

{
  "deals": [
    {
      "id": 0,
      "startsAt": "date in future",
      "endsAt": "date"
    },
    {
      "id": 1,
      "startAt": "date that is < NOW() meaning it already started",
      "endsAt": "date"
    }
    ]
}

I'm trying to make an aggregation that would change the list of objects to CONTAIN ONLY the deals that have started, meaning that it would return this

{
  "deals": [
    {
      "id": 1,
      "startAt": "date that is < NOW() meaning it already started",
      "endsAt": "date"
    }
  ]
}

Is this possible in ElasticSearch? if so, please attach some code examples in your response, really appreciated!

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