我一直在尝试使用来自 Algolia 的查询参数过滤初始搜索,但没有成功。 我在文档中读到的是您必须添加查询参数和查询字符串,但到目前为止它已经完成了这项工作。
这是我一直在使用的代码
var search = instantsearch({
appId: 'API ID',
apiKey: 'APY KEY SEARCH',
indexName: 'per_posts_product',
searchParameters: {
facets: ['taxonomies.product_cat'],
facetsRefinements: {'taxonomies.product_cat': 'Dual Daggers'}
},
routing: true
});
最佳答案
提供给facetsRefinements
的值应该是数组而不是字符串。这是一个展示如何使用它的示例:
const search = instantsearch({
appId: 'APP_ID',
apiKey: 'API_KEY',
indexName: 'INDEX_NAME',
searchParameters: {
facets: ['taxonomies.product_cat'],
facetsRefinements: {
'taxonomies.product_cat': ['Dual Daggers'],
},
},
});
不要忘记将您的属性声明为 attributesForFaceting
在你的索引中。
关于javascript - instantsearch.js:使用来自 Algolia 的查询参数过滤初始搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54888113/