But, queries with { ’ field ’ : { ’ $ne ’ : null }}, { ‘field’ : value } does not use this partial index. How can I create Partial index for such queries?
Instead, you can create an index with $exists: true expression, and make sure you don’t save property with a null value in a collection otherwise it will consider it as exist field.
And in your query you can check { 'field': { '$exists': true, '$eq': "value" } }
You can use the $or operator to check multiple types, it is supported by MongoDB v6.
“Error in specification { key: { field: 1.0 }, name: "field_1", partialFilterExpression: { field: { $type: { $in: [ "int", "double" ] } } } } :: caused by :: type must be represented as a number or a string”,
As you can read from the error message, The $type operator does not allow another operator as value except its types, instead, you can use $or operator,