Partial Filter Expression with varying date range

Hello Team,

Does mongo support creating of indexes with partial expression having a condition CreatedDate: $gte and $lte <CurrentDate+6months>. Potentially index only documents in my collection having CreatedDate in -6 to +6 months.

Regards,
Laks

Hello @Laks, Welcome back to the MongoDB community forum,

I would suggest you take a look at the Partial Index doc,

CurrentDate is a fixed value once processed. So yes, but only for “today” + 6 and “today” - 6.

i don’t think mongodb server will re-evaluate this expression every day.