{ keys: {description: 'text', title: 'text'}, options: { weights: { title: 10, // Title fields are more important description: 5 // Description fields are less important }, name: 'TextIndex' // Custom name for the index }}
The options object can include the following properties:
Copy
{ unique: boolean, // Whether the index should be unique sparse: boolean, // Only index documents that have the indexed field expireAfterSeconds: number, // Time to live for indexed documents name: string, // Custom name for the index background: boolean, // Create the index in the background partialFilterExpression: object, // Filter expression for partial indexes collation: object, // Language-specific collation rules // ... other MongoDB index options}