Skip to Main Content

MongoByte MongoDB Logo

Welcome to the new MongoDB Feedback Portal!

{Improvement: "Your idea"}
We’ve upgraded our system to better capture and act on your feedback.
Your feedback is meaningful and helps us build better products.

Status Completed
Categories Atlas Search
Created by Guest
Created on May 26, 2023

Ability to exclude documents matching a certain criteria from index

We don't do physical deletion of documents, but a logical one, flagging them by setting a value for a `deleted_at` field. We would like an option to exclude documents where that field exists and is not null from the index, because they will never be returned and are only consuming space of the index. Currently we use a `mustNot` condition to exclude them, but of course they are still being indexed. The ideal would be to be able to define the exclusion criteria in the index definition.
  • ADMIN RESPONSE
    Oct 18, 2025
    This can now be achieved using a view with a $match stage. See docs here ( https://www.mongodb.com/docs/atlas/atlas-search/view-support/#example--filter-documents ). Please don't hesitate to reach out if you have any feedback.
  • Guest
    Sep 30, 2025
    Hi Amy, thanks for your response! Yes, I've been aware of this update, but I couldn't make it work yet. When I try to create a search index on a view I get the following error: "Collection 'view_name' does not exist". Any ideas how to fix that? I'm using version 8.0.10.