0
私はMongoDbを使ってデータを保存しているnodejsに既にビルドされた古いプロジェクトを持っています。 Mongodbのバージョンは2.4mongoose-text-searchが動作しません
です。問題は、コレクション上でテキスト検索を実行していますが、console.log(引数)を意味する何も返されません。それはスキーマが のvarスキーマでいます私はMongoの端末でdb.socialposts.runCommand("text", { search: "accessories",limit: 1 })
を実行することができるよ、みんなに知らせるためだと
var options, search;
options = {
limit: 1
};
search = 'accessories';
console.log(search);
SocialPost.textSearch(search, options, function(err, out) {
console.log(arguments);
return true;
});
何
を印刷しない飽きません。
schema = new mongoose.Schema({
entity_id: {
type: mongoose.Schema.Types.ObjectId,
required: true
},
social_id: {
type: String,
required: true
},
type: {
type: String,
required: true
},
app: {
type: String,
required: true
},
date: {
type: Date,
required: true
},
url: {
type: String,
required: true
},
post: {
type: String
},
title: {
type: String
},
image: {
type: String
},
video: {
type: String
},
hashtags: [String]
}, {
strict: 'throw'
});
インデックスが
schema.index({
type: 1,
social_id: 1
});
schema.index({
type: 1,
entity_id: 1,
date: 1
});
schema.index({
title: 'text',
post: 'text'
});