Querying and sorting using collation and indexes

Even though the documentation clarifies that if an index has a collation, then a query will only use it if it specifies the same collation (but it doesn’t say that an index without collation cannot be used by a query with collation), I think it is not all good that an index without collation can be used in a query with collation (https://docs.mongodb.com/manual/reference/collation/).

It happened to me that, having a case-sensitive text field, I had to make a query sorting by that field but using the alphabetical order (case-insensitive). While I specified the collation in the query (which results in the collation being inserted into the command object), the result of the query is that the field values ​​were sorted using binary comparison (case-sensitive). Analyzing the queryPlanner, I could see that the collation was not taken into account and the index without collation was used, causing the order to be defined by said index. If I also apply a filter on this field in the query to search for a word with characters similar to an existing value but not identical (differences in diacritics), the comparison correctly applies the specified collation and returns a correct result. In other words, for the filtering process the collation is applied correctly but for the sorting process the index is used, ignoring the specified collation and generating a wrong result.

That being said, if the collation is applied at the cursor level, the sorting is done correctly and the result is as expected.

PS: sorry for my english, I’m not native and did my best with google translate.