小编Mik*_*nov的帖子

不能在String中使用$ text

此代码转储为异常

self.staticVars.Model
        .find({shortAddress: {$text : { $search: data.text }}, _town: data._town},{limit: 10})
        .populate('_street _district')
        .sort({house: 1})
        .exec(callback);
Run Code Online (Sandbox Code Playgroud)

例外

Can't use $text with String
Run Code Online (Sandbox Code Playgroud)

模型

shortAddress: {
    type: String
},
Run Code Online (Sandbox Code Playgroud)

指数

collection.ensureIndex({fullAddress: 'text', shortAddress: 'text'}, { default_language: "russian" },function(){});
Run Code Online (Sandbox Code Playgroud)

mongoose mongodb node.js node-mongodb-native

5
推荐指数
1
解决办法
1762
查看次数

标签 统计

mongodb ×1

mongoose ×1

node-mongodb-native ×1

node.js ×1