var animalSchema = new Schema({
name: String,
type: String,
tags: { type: [String], index: true } // field level
});
animalSchema.index({ name: 1, type: -1 }); // schema level
1和-1分别表示升序索引和降序索引
原文:https://www.cnblogs.com/mengfangui/p/12263358.html