Articles → MONGODB → Partial Index In Mongodb

Partial Index In Mongodb






Purpose





Example




Picture showing the sample document collection




db.restaurants.createIndex(
   { borough: 1, cuisine: 1 },
   { partialFilterExpression: { 'rating.grade': { $eq: "A" } } }
)




db.restaurants.find( { borough: "Bronx", 'rating.grade': "A" } ).explain("executionStats")




Picture showing the output of partial index in mongodb





Posted By  -  Karan Gupta
 
Posted On  -  Monday, April 29, 2024

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250