Closed zyonnetworks closed 7 years ago
maybe your users don't have any emails?
There are emails, i even tried without searching for emails and still no luck. It should work out the box meaning no special subscriptions or publications, correct?
import { Meteor } from 'meteor/meteor';
import { Index, MongoDBEngine } from 'meteor/easy:search';
const UsersIndex = new Index({
collection: Meteor.users,
fields: ['username', 'createdAt'],
engine: new MongoDBEngine({
selectorPerField: function (field, searchString) {
return this.defaultConfiguration().selectorPerField(field, searchString)
}
});
console.log(UsersIndex.search('').fetch());
same here!
// verisons
easy:search@2.1.6
easysearch:components@2.1.5
easysearch:core@2.1.6
// indexes.js
export const MessagesIndex = new Index({
collection: Messages,
engine: new MongoDBEngine({
//
}),
fields: ['content'],
})
// search.html
<template name="messagesSearch">
{{> EasySearch.Input index=MessagesIndex }}
<ul>
{{#EasySearch.Each index=MessagesIndex}}
<li>Content: {{content}}</li>
{{/EasySearch.Each}}
</ul>
{{> EasySearch.LoadMore index=MessagesIndex}}
{{#EasySearch.IfNoResults index=MessagesIndex}}
<div class="no-results">No results found!</div>
{{/EasySearch.IfNoResults}}
</template>
// search.js
Template.messagesSearch.helpers({
MessagesIndex: function () {
console.log(Messages.find({}).fetch());
console.log(MessagesIndex.search('').fetch());
return MessagesIndex;
},
})
console.log(Messages.find({}).fetch());
returns something like [Document, Document, Document]
console.log(MessagesIndex.search('').fetch());
returns an empty array [] all the time.
Well, switching to MinimongoEngine solved the problem.
It's weird, because no matter which engine I use, console.log(Messages.find({}).fetch());
shows the same results in my console.
And I wanna use beforePublish function in MongoDBEngine actually.
how about searching for a letter? does that return users? It might be that the mongodb selector returned by selectorPerField
is outdated.
Why doesn't this work? I know it's in http://matteodem.github.io/meteor-easy-search/docs/recipes/ and that's what i followed, but it always returns empty array []
I have this defined on the Client