【发布时间】:2016-03-19 17:55:39
【问题描述】:
我创建了一个包含名称和描述字段的类别集合。即
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 );
我需要创建一个文本索引来按名称或描述查找类别。 我看到了Meteor js: Create index in user collection,但这不是我的需要,我也试过了
Meteor.startup(function () {
Categories._createIndex(
{ 'translation.$.name' : "text" },
{ 'translation.$.description' : "text" },
{ default_language: "english" }
);
});
我读到了关于在流星中创建索引但它不起作用或者我做错了什么?任何帮助将不胜感激。
【问题讨论】:
标签: javascript mongodb meteor