matteodem / meteor-easy-search

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

Auto-Suggest Not Working #453

Closed ritchieng closed 8 years ago

ritchieng commented 8 years ago

Hi,

I got this amazing package working. However, when I tried out the "auto-suggest". The suggestions appeared. However, the results did not appear as like without auto-suggest (just the normal search).

May I know with auto-suggest, am I required to change anything like the helper etc.?

matteodem commented 8 years ago

Do you have a reproduction repository?

ritchieng commented 8 years ago

My repo is on bitbucket. Thanks for replying, was waiting for a fix on this.

But here's what I did. @matteodem

1: Added meteor easy-search package and easy-search:autosuggest package 2: Added these lines to /both/profile.js to configure collection

ProfilesIndex = new EasySearch.Index({
    collection: Profiles,
    fields: ['name','title','location'],
    engine: new EasySearch.Minimongo()
});

3: Added these lines to configure search without auto-suggest. This works!

<template name="profiles">

    <div class="container">
        <div class="row">
            <div class="col-sm-4">
                Search &nbsp;{{> EasySearch.Input index=profilesIndex}}

            </div>


            {{#EasySearch.IfInputEmpty index=profilesIndex }}

            {{else}}
                {{#if resultsCount}}
                    <div class="padded count-results">{{resultsCount}} results found.</div>
                {{/if}}
            {{/EasySearch.IfInputEmpty}}
        </div>
    </div>
    <hr>
    <br />
    {{#EasySearch.IfSearching index=profilesIndex }}
        <div>Searching...</div>
    {{/EasySearch.IfSearching }}

    <div class="row">
        {{#EasySearch.Each index=profilesIndex }}
            {{> profileSmall}}
        {{/EasySearch.Each}}
    </div>

    {{> EasySearch.LoadMore index=profilesIndex}}

    {{#EasySearch.IfNoResults index=profilesIndex}}
        <div class="no-results">No results found. Try searching for another name!</div>
    {{/EasySearch.IfNoResults}}

    {{> EasySearch.Pagination index=profilesIndex maxPages=10 }}

    <div class="text-center">
        {{> infiniteScroll }}
    </div>
</template>

4: The moment I try auto-suggest, it doesn't work anymore. {{> EasySearch.Autosuggest index=profilesIndex}}


matteodem commented 8 years ago

Please show me errors you are receiving and / or template helper code.

ritchieng commented 8 years ago

There's no error in the console. But here's the helper code.

Template.jobs.onCreated(function() {
    this.infiniteScroll({
        perPage: 30,
        subManager: subs,
        collection: Jobs,
        publication: 'jobs'
    });
});

Template.jobs.helpers({
    "jobs": function() {
        return Jobs.find({}, {
            sort: {
                featuredThrough: -1,
                createdAt: -1
            }
        });
    },
    "attributes": function() {
        return { class: 'btn btn-primary btn-md'};
    }
});

Template.jobs.helpers({
        companiesIndex: () => CompaniesIndex
});

The "suggestions" underneath the search bar do come up. But it just doesn't load the content like when I'm using without autosuggest.

matteodem commented 8 years ago

What do you mean with following:

it just doesn't load the content

ritchieng commented 8 years ago

When you search "chocolate", the suggestions appear.

However the results do not appear below in

{{#EasySearch.Each index=companiesIndex}}
{{/EasySearch.Each}}

Normally the results would appear.

matteodem commented 8 years ago

The idea of the autosuggest is that it is self contained and has no direct relation with the Each component.

ritchieng commented 8 years ago

But do you get my point of how the original package allows the results to filter but once you use autosuggest it doesn't.

Does it mean the autosuggest is just for displaying "suggestions" without loading the results like in the original package you made that works well?

matteodem commented 8 years ago

What do you mean by filter? You can still have a selector method that allows you to filter the searchable set of data. You can use the autosuggest to provide a select 2 autosuggest.

Can you simply explain your use-case in 2 to 5 sentences?

ritchieng commented 8 years ago

@matteodem I've a repo at bitbucket, do you've an email/user where I can send to you to view?

matteodem commented 8 years ago

Please just try to explain your use-case, I don't have time to have a look at the repo.

ritchieng commented 8 years ago

I'm using weworkmeteor's exact same code: https://github.com/nate-strauser/wework

I'm just trying to implement autosuggest for that, and my code was trying to implement that in that particular case under https://github.com/nate-strauser/wework/blob/master/client/views/profiles/profiles.html

Thanks.