Case-insensitive indexes support queries that perform string comparisons without regard for letter case, and with MongoDB 3.4's support of Collation, these are now possible to build. Collation gives you the ability to specify language-specific rules for string comparison. Since MongoDB’s previous versions did not support Collation, you were limited to performing a case-sensitive index comparison. In the scenarios that needed case-insensitive behavior, the only option was to convert/store all of your strings to either uppercase or lowercase and then do the comparison. As you can imagine, this causes a lot of hassle with queries and index operations.
Creating a MongoDB Case-Insensitive IndexThe Collation property can be set at the collection level or explicitly when creating an index. If set at the collection level, it doesn’t need to be specified with every create-index command on, as the index inherits the Collation of the collection. Unless specified explicitly during creation time, a collection has no Collation associated with it. You can determine the Collation details of your collection using commands provided below:
No comments:
Post a Comment