1.partialFilterExpression: what it accepts, and sizing the reduction
partialFilterExpression accepts equality, $exists, comparison ($gt/$gte/$lt/$lte), $type, $and, $or, $in, and the geospatial $geoWithin/$geoIntersects operators — a real but not unlimited subset of the query language ($regex and several others are not supported). Size reduction is worth measuring, not assuming: count how many documents actually match the filter versus the full collection.
Key features
- Supported: equality/$eq, $exists: true, $gt/$gte/$lt/$lte, $type, $and, $or, $in, $geoWithin, $geoIntersects
- Not every query operator is supported — check the current manual before relying on one not listed here
- The filter is evaluated once per document at write/index-build time, not re-evaluated per query
- Size reduction ≈ 1 − (matching document count ÷ total document count) — measure it, do not assume it
- A partial index with a filter matching most of the collection saves little size for the added complexity
Command
{ partialFilterExpression: { <field>: { $exists: true } } } // equality, comparison, $and/$or/$in also supportedpartialFilterExpression supports equality, $exists, comparison operators, $type, $and, $or, $in, and geospatial operators — check the current manual before assuming an operator is unsupported. Measure the real size reduction (matching vs. total document count) rather than assuming it.