matteodem / meteor-easy-search

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

subscription using MongoDBEngine #596

Closed daorren closed 7 years ago

daorren commented 7 years ago

The MongoDB engine searches the specified collection directly with MongoDB on the server and uses subscriptions to retrieve reactive data
-- MongoDBEngine

When I use MongoDBEngine, I'm not getting all the data from server side database

Index here only get subscription from its context template, which is the same result when I use MinimongoEngine.

So should I specify which subscription to use? But how?

// indexes.js
export const MessagesIndex = new Index({
  collection: Messages,
  engine: new MongoDBEngine({
    //
  }),
  fields: ['content'],
})

// conversation.html
<template name="conversation">
  {{> messagesSearch}}
<template>

// 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;
  },
})
matteodem commented 7 years ago

did you create the index on both the server and client? the easy search leaderboard example can also give you a hint maybe.