166 — CommandNotSupportedOnView

queryconfiguration

This command cannot be executed against a view

What is happening?

CommandNotSupportedOnView is returned when a command that only works on collections is executed against a view. Views are stored aggregation pipelines and do not support operations like createIndex, insert, update, delete, findAndModify, mapReduce, or compact. Read operations (find, aggregate) work on views but write operations do not.

Common causes

  1. Attempting to insert, update, or delete documents on a view
  2. Trying to create an index on a view
  3. Running compact, validate, or reIndex against a view
  4. Application code not distinguishing between collections and views

Source code references

ErrorCodes::CommandNotSupportedOnView found in 32 locations in the MongoDB server source.

Diagnostic Steps

Related Issues