Meteor js: Create text index in collection

Viewed 1156

I created a category collection with a name and description field. i.e

Categories = new Meteor.Collection('categories');

CategoriesSchema = new SimpleSchema({
    translation:{
        type: [Object]
    },
    "translation.$": {
        type: Object
    },
    "translation.$.name": {
        type: String
    },
    "translation.$.description": {
        type: String
    }
});

Categories.attachSchema( CategoriesSchema );

I need to create a text index to find categories by name or description. i saw Meteor js: Create index in user collection but that not about my need i also tried

Meteor.startup(function () {
    Categories._createIndex(
        { 'translation.$.name' : "text" },
        { 'translation.$.description' : "text" },
        { default_language: "english" }
    );
});

I read about create Index in the meteor but it did not work or I did that wrong? any help will be greatly appreciated.

1 Answers
Related