Reputation: 933
Using meteor easy-search I have an Index on my user collection :
UserIndex = new EasySearch.Index({
collection: Meteor.users,
fields: ['username', 'realname', 'bio', 'email'],
engine: new EasySearch.MongoDB(),
});
And a query in my client :
var userResults = UserIndex.search(input).fetch();
The first time I fetch for an input, the index returns empty, the second time it works normally. It works that way when I change inputs: first time empty, second time works ok. I have no clue why it behaves that way... Any idea?
Upvotes: 0
Views: 107
Reputation: 1399
You have to give time for your search results to be published to the client. Try wrapping your search in a Tracker.autorun
, like:
Tracker.autorun(() => {
let userResults = UserIndex.search(input).fetch();
console.log(userResults);
});
Watch the logged results after making one search; they'll start empty but then as the results are published to the client, you'll see the proper results logged.
Upvotes: 1