The*_*zle 0 javascript jquery algolia
我正在尝试将Algolia的自动完整结果过滤回我的应用程序.我添加了过滤器以检查draft=0我在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;
}
}
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,它不会过滤并仍然返回草稿内容.我不希望在搜索中显示的文章draft: 1在我的algolia索引中.
小智 6
filters是数据源的参数而不是autocomplete自身.
尝试:
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;
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
800 次 |
| 最近记录: |