Skip to content

autoIndex does not use Schema collation to create index #9912

Closed
@jeremyml

Description

@jeremyml
var UserSchema = mongoose.Schema({
  firstName: {type: String, index: true}
},{autoIndex : true, collation: { locale: 'en' }});

db.user.getIndexes();

    {
        "v" : 2,
        "key" : {
            "firstName" : 1
        },
        "name" : "firstName_1",
        "ns" : "db.user",
        "background" : true
    },

There is no en collation on the index created by autoIndex . I may write a startup script to perform the autoIndex function with the collation options set on the Schema. Mongoose ignores the Schema collation when autoIndex creates an index (uses collection default collation instead).

Seems related to this other issue: #7621

Metadata

Metadata

Assignees

Labels

confirmed-bugWe've confirmed this is a bug in Mongoose and will fix it.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions