Index collation

30 views
Skip to first unread message

Amel

unread,
Dec 15, 2017, 8:19:43 AM12/15/17
to mongodb-user
I have found that my index contains collation :

{
                "v" : 2,
                "key" : {
                        "_id" : 1
                },
                "name" : "_id_",
                "ns" : "DB1.Col1",
                "collation" : {
                        "locale" : "fr",
                        "caseLevel" : false,
                        "caseFirst" : "off",
                        "strength" : 3,
                        "numericOrdering" : false,
                        "alternate" : "non-ignorable",
                        "maxVariable" : "punct",
                        "normalization" : false,
                        "backwards" : false,
                        "version" : "57.1"
                }
        },



because all indexes contain the same collation and i need them to cancel the collation.

I want to delete the collation ? How should i do it ? 

Kevin Adistambha

unread,
Jan 1, 2018, 8:17:46 PM1/1/18
to mongodb-user

Hi

Currently you would have to recreate the index if you want to remove the collation in the index.

If all your indexes are created with that collation, it is possible that the collection has a default collation in place. The default collation for a collection can be specified as part of the db.createCollection() command. If a collection has a default collation:

  • Indexes on that collection will be created with that collation unless the index creation operation explicitly specify a different collation.
  • Operations on that collection use the collection’s default collation unless they explicitly specify a different collation.

You can check if the collection has a default collation set up using the db.getCollectionInfos() command. For example:

test> db.createCollection('testcollation', {collation:{locale:'en'}})
{
  "ok": 1
}
test> db.getCollectionInfos({name:'testcollation'})
[
  {
    "name": "testcollation",
    "type": "collection",
    "options": {
      "collation": {
        "locale": "en",
        "caseLevel": false,
        "caseFirst": "off",
        "strength": 3,
        "numericOrdering": false,
        "alternate": "non-ignorable",
        "maxVariable": "punct",
        "normalization": false,
        "backwards": false,
        "version": "57.1"
      }
    },
    "info": {
      "readOnly": false
    },
    "idIndex": {
      "v": 2,
      "key": {
        "_id": 1
      },
      "name": "_id_",
      "ns": "test.testcollation",
      "collation": {
        "locale": "en",
        "caseLevel": false,
        "caseFirst": "off",
        "strength": 3,
        "numericOrdering": false,
        "alternate": "non-ignorable",
        "maxVariable": "punct",
        "normalization": false,
        "backwards": false,
        "version": "57.1"
      }
    }
  }
]

There is currently no method to remove a collections’ default collation. If your collection has a default collation, you would need to recreate the collection.

Best regards
Kevin

Reply all
Reply to author
Forward
0 new messages