Mongodb version 4.2 Can a partial index be used while sharding the collection

89 views Asked by At

My collection has only parital index on one key . I want to shard the collection based on that partial indexed key, is it possible in mongodb 4.2, not able to figure it out from official documentation.

sample document in the collection

{ "_id" : ObjectId("5f16c2d0XYZ"), "company_url" : "https://www.linkedin.com/company/XYZ", "website" : "XYZ.com" }

partial index created like this:

db.collection.createIndex({"website":1}, { partialFilterExpression: { "website": { "$exists": true } } })

my cluster consists of 4 shards. I want to know even if its possible to shard, is it recommended?

0

There are 0 answers