Just to point out, do not name a field "language" if you are planning to create an index

Maybe I am mistaken, but just wanted to share my experience.

I am a Digital Humanities technician, and I am having my first approach to indexes in MongoDB. My current project requires to create a database about medieval manuscripts, which would include information such as “Country of creation”, “Scribe”, “Ink type” and so on. The thing is that I cannot use the word “Language” to indicate which language was used to write each one of the manuscripts, because Mongo will believe that I am trying to define the language of the index, and thus, will return the following error:

Index build failed: 4400000-0000-406e-0080-00e2253a7d93: Collection MyCollection ( 0d0000-0005-4001-9000-37cbe9cd0000 ) :: caused by :: language override unsupported:

I will look for an alternative name for that field to avoid said error. I wanted to leave this piece of advise here just in case any other DH baby (like me) is having the same issue.


Hi @Irene_Rincon

Field name restrictions are documented here: https://www.mongodb.com/docs/manual/core/document/#field-names

Can you add what driver is being used and versions of mongodb and driver. As well as how the index is being defined.

Using language as a field name or index name is not an issue: mongosh 2.1.1, mongodb 7.0.1

  { language: 'eng', foo: 'bar' }, 
  { language: 'fra', foo: 'baz' }

  createIndexes: 'foo', 
  indexes: [
    { key: { language: 1 }, name: 'language' }, 
    { key: { language: -1 }, name: 'language_desc' }

  { v: 2, key: { _id: 1 }, name: '_id_' },
  { v: 2, key: { language: 1 }, name: 'language' },
  { v: 2, key: { language: -1 }, name: 'language_desc' }

Very cool.


Thank you, Chris! Maybe I should have mentioned that I manage my db via Compass, since is more friendly for someone who has just learned how to code (like myself). Unfortunately, Compass doesn’t let you configure indexes like the shell.

In any case, I will try to use your example as a guide to improve my index.

Oh, I’m off to try in compass myself now. Could be a bug :beetle:

There is a shell built into Compass. Black bar at the bottom or Ctrl + `` (backtick) .

So no need to install another tool.

1 Like


Can you provide reproduction steps? And the version of Compass?

By checking your code I just figured out what the issue was. I was defining the index type as “text”, instead of “1”. If I create the index as you did, I don’t have any problem by naming my field as “language”.

I guess this is what happens when you start messing around with software before understanding it.

Thank you again. I am not sure if I should delete this post, or leave it for people like me.


Leave the post, one day someone will do the exact same thing, and here is a post about it!

1 Like

Please leave the post. This is important knowledge.


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