matteodem / meteor-easy-search

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

Auto-suggest does not work with selectors #417

Closed holwech closed 7 years ago

holwech commented 8 years ago

I could be missing something, but this works perfectly when using the normal input component. It also works without any selectors, but with a selector no suggestions appear at all.

client

Template.tools.helpers({
    commentsIndex: function() {
        return CommentsIndex;
    }
});
<template name='tools'>
    <div class='row'>
        <div class="autosuggest-component">
            {{> EasySearch.Autosuggest index=commentsIndex}}
        </div>
    </div>
</template>

Setting the selector-value

setSearchLanguage = function(lang) {
    CommentsIndex.getComponentMethods()
        .addProps('language', lang);
}

server

CommentsIndex = new EasySearch.Index({
    collection: Comments,
    fields: ['comment'],
    engine: new EasySearch.MongoDB({
        selector: function (searchObject, options, aggregation) {
            let selector = this.defaultConfiguration().selector(searchObject, options, aggregation);
            selector.language = options.search.props.language;
            return selector;
        }
    })
});
matteodem commented 8 years ago

This has to do with the autosuggest component not using the component methods. I'll have a look at this soonish

Tzikas commented 8 years ago

+1 Same issue. Thank you.

matteodem commented 7 years ago

This is fixed in the latest version 2.1.6.