<!-- llms-explorer concept facts · https://llms-explorer.com/tree/custom-criteria/ · pack 2026-10-15 · ~1507 tokens -->

# CUSTOM Criteria

> Depth-first rabbithole dossier for CUSTOM Criteria; source-anchored research pack.

Parent: [Archive Rules](https://llms-explorer.com/tree/archive-rules/) · 4 facets · 13 facts · page: https://llms-explorer.com/tree/custom-criteria/

## How it works

- [low] It is recommended to check the query execution plan to ensure the query is efficient when using $expr in custom criteria. Sources: https://mongodb.com/community/forums/t/online-archive-custom-criteria-with-isodate/163895 — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/custom-criteria-6de676fde9/rabbithole-synthesis.md#core`
- [low] The criteria field is conditional and not required when the type is equal to CUSTOM. Sources: https://raw.githubusercontent.com/mongodb/terraform-provider-mongodbatlas/master/internal/service/onlinearchive/resource.go — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/custom-criteria-6de676fde9/rabbithole-synthesis.md#core`
- [high] For DATE criteria, when the current date exceeds the specified date field value, Atlas subtracts the number of days from the current time and archives data after that time. Sources: https://www.mongodb.com/docs/atlas/online-archive/overview.md, https://www.pulumi.com/registry/packages/mongodbatlas/api-docs/onlinearchive/ — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/custom-criteria-6de676fde9/rabbithole-synthesis.md#core`

## Problems, failure modes and limitations

- [medium] Online Archive requires Custom Criteria to be formatted in strict JSON, meaning functions like ISODate or Date cannot be used directly in date comparisons. Sources: https://jira.mongodb.org/browse/MONGOSH-1849, https://mongodb.com/community/forums/t/online-archive-custom-criteria-with-isodate/163895 — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/custom-criteria-6de676fde9/rabbithole-synthesis.md#core`
- [low] Custom criteria that use the $expr workaround (for example on _id) will likely not use an index, making the archival process slow. Sources: https://mongodb.com/community/forums/t/online-archive-using-id/277894 — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/custom-criteria-6de676fde9/rabbithole-synthesis.md#troubleshooting`
- [low] You cannot change the archiving criteria from Date Match to Custom Filter, or vice versa, once the online archive is created. Sources: https://www.mongodb.com/docs/atlas/online-archive/manage-online-archive.md — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/custom-criteria-6de676fde9/rabbithole-synthesis.md#core`
- [high] You cannot pass an empty document {} to the custom query to return all documents. Sources: https://www.mongodb.com/docs/atlas/online-archive/manage-online-archive.md, https://raw.githubusercontent.com/mongodb/terraform-provider-mongodbatlas/master/docs/resources/online_archive.md, https://www.pulumi.com/registry/packages/mongodbatlas/api-docs/onlinearchive/ — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/custom-criteria-6de676fde9/rabbithole-synthesis.md#core`

## Comparisons and alternatives

- [low] The recommendation for optimizing archiving speed is to create a new indexed date field rather than using custom criteria with $expr and _id. Sources: https://mongodb.com/community/forums/t/online-archive-using-id/277894 — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/custom-criteria-6de676fde9/rabbithole-synthesis.md#patterns`

## Facts and statements

- [high] For CUSTOM criteria, Atlas uses the specified query with the db.collection.find(query) command, and custom queries do not support JavaScript expressions. Sources: https://www.mongodb.com/docs/atlas/online-archive/manage-online-archive.md, https://raw.githubusercontent.com/mongodb/terraform-provider-mongodbatlas/master/docs/resources/online_archive.md, https://www.pulumi.com/registry/packages/mongodbatlas/api-docs/onlinearchive/ — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/custom-criteria-6de676fde9/rabbithole-synthesis.md#core`
- [low] The strict JSON representation of dates required for Online Archive Custom Criteria is not currently supported by mongosh. Sources: https://jira.mongodb.org/browse/MONGOSH-1849 — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/custom-criteria-6de676fde9/rabbithole-synthesis.md#core`
- [medium] You can incorporate the $expr operator as a workaround in custom criteria of Online Archive, but Atlas might convert a value before evaluating it against the query. Sources: https://mongodb.com/community/forums/t/online-archive-using-id/277894, https://mongodb.com/community/forums/t/online-archive-custom-criteria-with-isodate/163895 — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/custom-criteria-6de676fde9/rabbithole-synthesis.md#core`
- [high] There are two types of archiving criteria: DATE, which selects documents based on a date, and CUSTOM, which selects documents based on a custom JSON query. Sources: https://raw.githubusercontent.com/mongodb/terraform-provider-mongodbatlas/master/docs/resources/online_archive.md, https://raw.githubusercontent.com/mongodb/terraform-provider-mongodbatlas/master/internal/service/onlinearchive/resource.go, https://www.pulumi.com/registry/packages/mongodbatlas/api-docs/onlinearchive/ — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/custom-criteria-6de676fde9/rabbithole-synthesis.md#core`
- [low] The sequence in which MongoDB Cloud slices collection data to create partitions starts with zero, and the criteria.dateField parameter defaults as the first item in the partition sequence. Sources: https://www.pulumi.com/registry/packages/mongodbatlas/api-docs/onlinearchive/ — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/custom-criteria-6de676fde9/rabbithole-synthesis.md#core`

## Related concepts

- Criteria — is a part of CUSTOM Criteria
- CUSTOM — is a part of CUSTOM Criteria
