Reputation: 1574
I am trying to filter auto complete results from Algolia back to my app. I've added the filter to check if draft=0
in the data i have stored in algolia.
autocomplete('#search-box', {hint: false}, [
{
source: autocomplete.sources.hits(index, {hitsPerPage: 5}),
displayKey: 'title',
filters: 'draft=0',
templates: {
suggestion: function(suggestion) {
return suggestion._highlightResult.title.value;
}
}
}
So far it doesn't filter and still returns draft content. The article I don't want to show in the search is draft: 1
in my indices on algolia.
Upvotes: 0
Views: 1021
Reputation: 705
filters
is parameter of the data source and not autocomplete
itself.
Try:
autocomplete('#search-box', {hint: false}, [
{
source: autocomplete.sources.hits(index, {hitsPerPage: 5, filters: 'draft=0'}),
displayKey: 'title',
templates: {
suggestion: function(suggestion) {
return suggestion._highlightResult.title.value;
}
}
}
Upvotes: 4