What is Tertiary level of comparison?

I want to make my Email field in my collection a case-insensitive index. The official docs say to use Collation for this, with a strength value of 1 or 2.

On the docs, it says that level 1 performs comparsion for base characters only, while level 2 also include diacritics.

I’d like to ask the following:

  • If my document Email field is gil@gmail.com. For level 1, this will pass: ġil@gmail.com, but with level 2 it won’t pass since it includes diacritics. Correct?
  • What is level 3? What does “tertiarty differences” mean? Can you give me examples using the example I provided?
  • Is there performance degrading when using indexes with collation? How does the string comparsion work behind the scenes? Should I just normalize the Email field to be lowercase when I add new users since collation might hurt performance?

Hi @Gil_M and welcome in the MongoDB Community :muscle: !

From my understanding, level 3 is case sensitive. So it will detect the difference between a and A.

  • à and A are identical in level 1 but different starting level 2.
  • a and A are identical in level 2 but different in level 3.

Performance with or without collation should be within statistical error margins.

I hope this helps.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.