Performing easy-search on page render

I use throughout my app with a fair amount of success but there are still some concepts in its API that I struggle with.

Right now I have a search bar at the top of my site that is an easy-search input component. When you type in it, it pops up a search interface (like atmosphere) that filters my content fine.

However, I configured it so that if you submit the form it takes you to a new route (‘search/[terms]’) to display a fuller listing of search terms. This I configured as a separate index.

this page also has its own search input at the top of the page. I can easily get the search terms from the url (I use flowrouter), but I can’t figure out how to:

  1. prepopulate the search input on that page (yes, I could use $.val(), but I imagine there must be a component method for this.
  2. perform the search and display the first results.

the docs refer to using:

// index instanceof Index
const cursor ='Marie')
const docs = cursor.fetch()

// do stuff

which is fine, if I do that in my onrendered I do get results:

    terms = FlowRouter.getParam('terms');
    console.log('terms:', terms);
    const cursor =;
    const docs = cursor.fetch();
    console.log('cursor', cursor);
    console.log('docs', docs);

that does spit out the docs in the console. But in my template, no results show up:

            {{> EasySearch.Input index=contentSearchPageIndex charLimit=2 noDocumentsOnEmpty=true attributes=searchBoxAttributes}}
            <small class="text-muted">{{start}} to {{end}} of {{count}} results</small>

            <ul class="list-group list-group-flush">a
              {{#EasySearch.Each index=contentSearchPageIndex }}
                {{>content_search_list_item item=this}}

I know I can make this work by defining a helper function that returns the cursor and manually setting the input to my URL value, but I figured there might be more standard way of doing it using easy-search api functions.



This turned out to be really easy to fix:

                  {{> EasySearch.Input indexes=searchIndexes charLimit=2 noDocumentsOnEmpty=true attributes=searchBoxAttributes}}

in the template and:

  searchBoxAttributes: function () {
    var terms = FlowRouter.getParam('terms');
    return {
      placeholder: 'Search...',
      type: 'search',
      title: "Enter the terms you wish to search for.",
      id: "search-page-input",
      size: "15",
      maxlength: "128",
      class: "form-search form-control",
      value: terms,

in the js.