How to give indexes to mongodb View

I have a View in mongodb i need to create indexes in that view model how can i do

Hi @Mehmood_Zubair and welcome to the MongoDB community forum!!

MongoDB views are basically read-only objects whose contents are formed through the aggregation pipeline being defined in the createView command.

Also, if you wish use indexes on the collection, you can define indexes on the original collection and utilise the indexes on the views by specify.
Please visit the documentation to learn more on the Indexes in MongoDB..

Alternatively, you can also create materialised view and create indexes on the same. See materialised view for details.

Let us know if you have any further queries.

Best Regards
Aasawari

3 Likes