Hi @Averell_Tran ,
This is an interesting result! I thought the same as you - that it would use the index.
Reading up on the docs, it still isn’t completely clear why the index isn’t being chosen in this case - it’s a bit ambiguous.
I’ve found that a more specific query matching the partialFilterExpression does use the index:
db.my_coll.find({
"item_number": {
"$eq": "2ae9dc2f-2ff6-4239-9b7a-cccb757fc912",
"$type": "string",
},
})
That query, specifying the type as well as the value, results in an IXSCAN, as you’d expect.
I think if you want the query to use the index without the extra type check, then you probably want to remove the type requirement from your index’s partialFilterExpression.
Hope this helps!
Mark