0
林试图在与角2流星全文检索,这正是我发布FUNC:流星全文搜索。在客户认购后,收集包含旧的搜索结果
Meteor.publish("search", (searchValue) => {
console.log(searchValue);
if (searchValue) {
return Nutrition.find(
{$text: {$search: searchValue}},
{
// `fields` is where we can add MongoDB projections. Here we're causing
// each document published to include a property named `score`, which
// contains the document's search rank, a numerical value, with more
// relevant documents having a higher score.
fields: {
'name.long': 1,
score: {$meta: "textScore"}
},
// This indicates that we wish the publication to be sorted by the
// `score` property specified in the projection fields above.
sort: {
score: {$meta: "textScore"},
},
limit: 20
}
);
} else {
return Nutrition.find({})
}
});
和客户端:
public searchProducts = _.debounce((query) => {
Meteor.subscribe('search', query);
Nutrition.find({}).subscribe(data=>{
console.log(data.length);
});
}, 500);
,但在每个订阅集合包含新值(来自实际搜索)和旧值(来自旧搜索)之后。
这是什么原因?我能做些什么来避免这种情况?