matteodem / meteor-easy-search

Easy-to-use search for Meteor with Blaze Components
MIT License
438 stars 68 forks source link

Searching unpublished data #519

Closed KudMath closed 7 years ago

KudMath commented 7 years ago

I'm trying to use this package to search data that's not been published to the client. I understand that this is possible however I can't quite figure it out. Help please :)

Currently my index is configured as such :

UserIndex = new EasySearch.Index({
    collection: Meteor.users,
    fields: ['username', 'realname', 'bio', 'email'],
    engine: new EasySearch.MongoDB({
           selectorPerField: function (field, searchString) {
              if ('emails' === field) {
                 // return this selector if the email field is being searched
                 return {
                   emails: {
                     $elemMatch: {
                        address: { '$regex' : '.*' + searchString + '.*', '$options' : 'i' }
                     }
                   }
                 };
              }
              // use the default otherwise
              return this.defaultConfiguration().selectorPerField(field, searchString);
  }),

});
KudMath commented 7 years ago

Removing the selectorPerField returns users. But how can I incorporate them (temporarily if possible) in the data that's accessible on the client? Also what's wrong with my selector?

matteodem commented 7 years ago

What is your use case?