Skip to content
Index type text does not support collation

Error “Index type ‘text’ does not support collation” in MongoDB

Gökhan Duman

When working with MongoDB, we prefer to use indexing to speed up our queries and take advantage of features like text search. However, in some cases, such as having the locale settings in Turkish, issues might arise, leading to the “Index type ‘text’ does not support collation” error.

What is the “Index type ‘text’ does not support collation” Error?

We encounter the “Index type ‘text’ does not support collation” error due to an incompatibility in the customization settings known as collation. For instance, I encountered this error when I set the database language to Turkish and tried to create a text index for full-text search.

Solution for the “Index type ‘text’ does not support collation Error

To resolve this error, we can adjust the collation settings. The easiest way to do this is by using MongoDB Compass. For those who, like me, only deal with backend and database parts when necessary, making adjustments through the interface is more reasonable.

You can easily connect to MongoDB Compass as a database user using the connection string.

Let’s continue with our index creation scenario. With the MongoDB Compass application, you can select any collection in the database and create an index.

mongodb create index

When we click the CREATE INDEX button, an index creation screen will appear. Here, we can select multiple fields and name our index.

mongo db create index

At this stage, since my database language is Turkish, I will encounter the “Index type ‘text’ does not support collation” error when creating the index.

text does not support collation

In fact, if we carefully examine the error message, we will see that it mentions the collation settings causing the error. Among them, let’s start by fixing the locale. For this, we need to activate the Use Custom Collation option in the Options section. In this section, there are various customizations such as locale, strength, caseLevel, caseFirst, and more.

Since I thought the main issue was the locale, I began by changing that. I tried tr, tr-search, and English languages. However, the error persisted. Among the language options, the term “simple” caught my eye. When I set the localization to “simple” the problem was solved.

mongodb collation options

I’m not sure about the potential negative effects of this customization on text searches. Nonetheless, I believe it can’t be worse than not being able to create an index.

In my scenario, after selecting “simple” as the locale, I was able to click the CREATE INDEX button and create the index. Based on this, I think that by identifying and changing the problematic collation value, the “Index type ‘text’ does not support collation” error can be resolved.

Leave a Reply

Your email address will not be published. Required fields are marked *