For example, I created this index:
db.test.createIndex({field1:1}, {partialFilterExpression:{field2:{$gt:10}}})
Index created successfully. Then I want to create second index:
db.test.createIndex({field1:1}, {partialFilterExpression:{field2:{$lte:10}}}
But above will give error IndexOptionsConflict
, but no error details, only dumps the index object.
I have tested to create such indexes on PostgreSQL and it works. How can I do this in MongoDB?
Best Answer
Sadly, a restriction of MongoDB:
Right now, you can only do this:
Or use composite indexes with a placeholder field: